repair-add.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view class="mx3" style="padding-bottom: 100rpx">
  3. <u-toast ref="uToast" />
  4. <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
  5. <view class="p3 bg-color-white" style="margin-top: -50rpx; border-radius: 20rpx">
  6. <u-form :model="form" ref="uForm">
  7. <u-form-item label="选择设备" required prop="running" :label-width="150">
  8. <u-input v-model="form.running" disabled @click="handleSelect" placeholder="请选择设备" type="select" />
  9. <!-- <u-select
  10. v-model="haltState"
  11. :list="runningList"
  12. @confirm="runningSubmit"
  13. ></u-select> -->
  14. </u-form-item>
  15. <common-popup :list="runningList" @select="runningSubmit" ref="popup" />
  16. <view class="main-color-text f-size-32 f-weight-6 mt-2">基本信息</view>
  17. <u-form-item label="设备名称" :label-width="150">
  18. <u-input v-model="form.sbName" disabled />
  19. </u-form-item>
  20. <u-form-item label="设备编号" :label-width="150">
  21. <u-input v-model="form.bianhao" disabled />
  22. </u-form-item>
  23. <view class="main-color-text f-size-32 f-weight-6 mt-2">报修信息</view>
  24. <!-- <u-form-item label="报修来源" prop="repair" required :label-width="150">
  25. <u-input
  26. v-model="form.repair"
  27. disabled
  28. @click="repairState = true"
  29. placeholder="请选择报修来源"
  30. type="select"
  31. />
  32. <u-select
  33. v-model="repairState"
  34. :list="repairList"
  35. @confirm="repairSubmit"
  36. ></u-select>
  37. </u-form-item>-->
  38. <!--
  39. <u-form-item label="紧急等级" prop="level" required :label-width="150">
  40. <u-input
  41. v-model="form.level"
  42. disabled
  43. @click="levelState = true"
  44. placeholder="请选择紧急等级"
  45. type="select"
  46. />
  47. <u-select
  48. v-model="levelState"
  49. :list="levelList"
  50. @confirm="levelSubmit"
  51. ></u-select>
  52. </u-form-item>
  53. <u-form-item label="故障类别" required prop="badType" :label-width="150">
  54. <u-input v-model="form.badType" disabled @click="badState = true" type="select" />
  55. <u-select v-model="badState" :list="badList" @confirm="badSubmit"></u-select>
  56. </u-form-item>-->
  57. <!-- <u-form-item
  58. label="工单类别"
  59. required
  60. prop="category"
  61. :label-width="150"
  62. >
  63. <u-input
  64. v-model="category"
  65. disabled
  66. @click="badState = true"
  67. type="select"
  68. />
  69. <u-select
  70. v-model="badState"
  71. :list="categoryMap"
  72. @confirm="badSubmit"
  73. ></u-select>
  74. </u-form-item> -->
  75. <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
  76. <tree-select v-model="form.sbCph" valueName="title" :data="sbPositionData"></tree-select>
  77. </u-form-item>
  78. <u-form-item label="是否停机" required prop="needStop" :label-width="150">
  79. <!-- <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
  80. type="select" /> -->
  81. <u-radio-group v-model="form.needStop" @change="radioGroupChange">
  82. <u-radio :name="0">
  83. 否
  84. </u-radio>
  85. <u-radio :name="1">
  86. 是
  87. </u-radio>
  88. </u-radio-group>
  89. </u-form-item>
  90. <u-form-item label="工单类别" required prop="category" :label-width="150">
  91. <u-input v-model="category" disabled @click="categoryState = true" placeholder="请选择工单类别"
  92. type="select" />
  93. <u-select v-model="categoryState" :list="categoryMap" @confirm="categorySubmit"></u-select>
  94. </u-form-item>
  95. <u-form-item label="紧急程度" required prop="level" :label-width="150">
  96. <u-input v-model="form.level" disabled @click="levelState = true" placeholder="请选择紧急程度"
  97. type="select" />
  98. <u-select v-model="levelState" :list="levelList" @confirm="levelSubmit"></u-select>
  99. </u-form-item>
  100. <u-form-item label="故障类型" required prop="repairErrorTypeId" :label-width="150">
  101. <u-input v-model="form.badType" disabled @click="errorTypeState = true" placeholder="请选择故障类型"
  102. type="select" />
  103. <u-select v-model="errorTypeState" :list="errorTypeList" @confirm="errorTypeSubmit"></u-select>
  104. </u-form-item>
  105. <u-form-item label="要求日期" prop="limitDate" :label-width="150">
  106. <u-input v-model="form.limitDate" disabled @click="limitDateShow = true" placeholder="请选择要求日期"
  107. type="select" />
  108. <u-picker mode="time" v-model="limitDateShow" :params="dateParams"
  109. @confirm="limitDateSubmit"></u-picker>
  110. </u-form-item>
  111. <u-form-item label="要求时间" prop="limitHours" :label-width="150">
  112. <u-input v-model="form.limitHours" type="number" placeholder="请输入要求时间(小时)" />
  113. </u-form-item>
  114. <u-form-item label="报修人" prop="actualUser" required :label-width="150">
  115. <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
  116. </u-form-item>
  117. <u-form-item label="故障描述" prop="content" required :label-width="150">
  118. <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
  119. </u-form-item>
  120. <!-- <u-select v-model="aShow" mode="mutil-column-auto" :list="aList" @confirm="confirm"></u-select>-->
  121. <u-form-item label="上传图片" :label-width="150">
  122. <u-upload width="180" height="180" max-count="6" :action="action" :file-list="fileList"
  123. @on-success="uploadSuccess" @on-remove="uploadRemove"></u-upload>
  124. </u-form-item>
  125. </u-form>
  126. <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
  127. <view class="p-fixed d-flex j-around a-center footer">
  128. <view class="main-color-bg text-color-white common" @tap="handleSubmit">提交</view>
  129. </view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. data() {
  136. return {
  137. form: {
  138. badType: '',
  139. running: '',
  140. sbName: '',
  141. sbCph: '',
  142. bianhao: '',
  143. halt: '',
  144. repair: '',
  145. remarks: '',
  146. actualUser: '',
  147. content: '',
  148. repairErrorTypeId: '',
  149. photo: '',
  150. level: '',
  151. // 传入的
  152. sbId: '',
  153. needStop: null,
  154. levelValue: '',
  155. source: '',
  156. limitDate: '',
  157. limitHours: ''
  158. },
  159. category: '',
  160. badState: false,
  161. badList: [],
  162. runningState: false, // 设备选择
  163. runningList: [],
  164. haltState: false, // 是否停机
  165. haltList: [],
  166. repairState: false, // 报修来源
  167. repairList: [],
  168. levelState: false,
  169. levelList: [],
  170. categoryState: false, // 工单类别
  171. errorTypeState: false, // 故障类型
  172. errorTypeList: [],
  173. limitDateShow: false, // 要求日期
  174. dateParams: {
  175. year: true,
  176. month: true,
  177. day: true
  178. },
  179. imagesList: [],
  180. action: this.$BaseTool.UserUtil.getUploadUrlIgnores(),
  181. // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
  182. /* header: {
  183. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  184. }, */
  185. fileList: [],
  186. sourceMap: {},
  187. levelMap: {},
  188. statusMap: {},
  189. needStopMap: {},
  190. categoryMap: [],
  191. haltDefaultValue: [0],
  192. rules: {
  193. running: [
  194. {
  195. required: true,
  196. message: '请选择设备',
  197. trigger: ['blur', 'change']
  198. }
  199. ],
  200. category: [
  201. {
  202. required: true,
  203. message: '请选择工单类别',
  204. trigger: ['blur', 'change']
  205. }
  206. ],
  207. halt: [
  208. {
  209. required: true,
  210. message: '请选择是否停机',
  211. trigger: ['blur', 'change']
  212. }
  213. ],
  214. repair: [
  215. {
  216. required: true,
  217. message: '请选择报修来源',
  218. trigger: ['blur', 'change']
  219. }
  220. ],
  221. actualUser: [
  222. {
  223. required: true,
  224. message: '请填写报修人',
  225. trigger: ['blur', 'change']
  226. }
  227. ],
  228. sbCph: [
  229. {
  230. required: true,
  231. message: '请填写设备使用位置',
  232. trigger: ['blur', 'change']
  233. }
  234. ],
  235. level: [
  236. {
  237. required: true,
  238. message: '请选择紧急等级',
  239. trigger: ['blur', 'change']
  240. }
  241. ],
  242. content: [
  243. {
  244. required: true,
  245. message: '请输入问题描述',
  246. trigger: ['blur', 'change']
  247. }
  248. ],
  249. repairErrorTypeId: [
  250. {
  251. required: true,
  252. message: '请选择故障类型',
  253. trigger: ['blur', 'change']
  254. }
  255. ]
  256. },
  257. // #ifdef MP-WEIXIN
  258. cursorSpacing: 50,
  259. // #endif
  260. // #ifndef MP-WEIXIN
  261. cursorSpacing: 0,
  262. // #endif
  263. sbBackId: '',
  264. aShow: false,
  265. address: '',
  266. sbPositionData: [],
  267. sbId: null,
  268. aList: []
  269. }
  270. },
  271. onShow() {
  272. this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
  273. if (this.userInfo) {
  274. this.form.actualUser = this.userInfo.realName
  275. }
  276. const pages = getCurrentPages()
  277. const currPage = pages[pages.length - 1]
  278. this.sbBackId = currPage.sbBackId
  279. this.sbId = currPage.sbBackId
  280. if (this.sbBackId) {
  281. this.$Http
  282. .fetchSbInfoIgnores({
  283. id: this.sbBackId
  284. })
  285. .then(res => {
  286. this.form.bianhao = res.data.no
  287. this.form.sbName = res.data.name
  288. this.form.sbCph = res.data.positionName
  289. this.form.running = res.data.name
  290. this.form.sbId = this.sbBackId
  291. })
  292. }
  293. },
  294. onLoad(options) {
  295. if (options && options.detailId) {
  296. this.sbId = options.detailId
  297. this.$Http
  298. .fetchSbInfoIgnores({
  299. id: options.detailId
  300. })
  301. .then(res => {
  302. this.form.bianhao = res.data.no
  303. this.form.sbName = res.data.name
  304. this.form.running = res.data.name
  305. this.form.sbId = options.detailId
  306. this.form.sbCph = res.data.positionName
  307. })
  308. }
  309. // this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  310. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  311. // );
  312. // for (const key in this.sourceMap) {
  313. // this.repairList.push({
  314. // label: this.sourceMap[key],
  315. // value: key
  316. // });
  317. // }
  318. // this.form.repair = this.repairList[0].label;
  319. // this.form.source = this.repairList[0].value;
  320. // this.levelMap = this.$DictCache.getLabelByValueMapByType(
  321. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  322. // );
  323. // for (const key in this.levelMap) {
  324. // this.levelList.push({
  325. // label: this.levelMap[key],
  326. // value: key
  327. // });
  328. // }
  329. // this.form.level = this.levelList[0].label;
  330. // this.form.levelValue = this.levelList[0].value;
  331. // this.statusMap = this.$DictCache.getLabelByValueMapByType(
  332. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  333. // );
  334. console.log(22)
  335. // 同步 PC 端报修提交字段:工单类别、紧急程度、故障类型字典
  336. const categoryMap = this.$DictCache.getLabelByValueMapByType(
  337. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  338. )
  339. for (const key in categoryMap) {
  340. this.categoryMap.push({
  341. label: categoryMap[key],
  342. value: key
  343. })
  344. }
  345. const levelMap = this.$DictCache.getLabelByValueMapByType(
  346. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  347. )
  348. for (const key in levelMap) {
  349. this.levelList.push({
  350. label: levelMap[key],
  351. value: key
  352. })
  353. }
  354. // 紧急程度默认一级,与 PC 端默认值保持一致
  355. // if (levelMap && levelMap['1']) {
  356. // this.form.level = levelMap['1']
  357. // this.form.levelValue = '1'
  358. // }
  359. this.$Http
  360. .getDictType({
  361. type: 'REPAIR_ERROR_TYPE'
  362. })
  363. .then(res => {
  364. this.errorTypeList = (res.data || []).map(item => ({
  365. label: item.label,
  366. value: item.value
  367. }))
  368. })
  369. this.$Http
  370. .getSbPositionTree().then(res => {
  371. this.sbPositionData = res.data
  372. })
  373. // const categoryMap = this.$DictCache.getLabelByValueMapByType(
  374. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  375. // )
  376. // for (const key in categoryMap) {
  377. // this.categoryMap.push({
  378. // label: categoryMap[key],
  379. // value: key
  380. // });
  381. // }
  382. // console.log(this.categoryMap)
  383. // this.needStopMap = this.$DictCache.getLabelByValueMapByType(
  384. // this.$DictCache.TYPE.YES_NO
  385. // )
  386. // for (const key in this.needStopMap) {
  387. // this.haltList.push({
  388. // label: this.needStopMap[key],
  389. // value: key
  390. // });
  391. // }
  392. // this.form.halt = this.haltList[this.haltDefaultValue].label;
  393. // this.form.needStop = this.haltList[this.haltDefaultValue].value;
  394. this.getType()
  395. // 获取设备数据
  396. // this.initSb();
  397. },
  398. onReady() {
  399. this.$refs.uForm.setRules(this.rules)
  400. },
  401. methods: {
  402. //
  403. confirm(e) {
  404. console.log(e)
  405. this.address = ''
  406. for (let i = 0; i < e.length; i++) {
  407. this.address += e[i].label
  408. }
  409. },
  410. badSubmit(data) {
  411. this.category = data[0].label
  412. this.form.category = data[0].value
  413. },
  414. // 工单类别
  415. categorySubmit(data) {
  416. this.category = data[0].label
  417. this.form.category = data[0].value
  418. },
  419. // 故障类型
  420. errorTypeSubmit(data) {
  421. this.form.badType = data[0].label
  422. this.form.repairErrorTypeId = data[0].value
  423. },
  424. // 要求日期
  425. limitDateSubmit(e) {
  426. this.form.limitDate = `${e.year}-${e.month}-${e.day}`
  427. },
  428. getType() {
  429. /* this.$Http
  430. .fetchErrorTypeTree({
  431. id: this.detailId
  432. })
  433. .then((res) => {
  434. console.log(res.data);
  435. const temp = []
  436. res.data.forEach(item => {
  437. temp.push({
  438. label: item.title,
  439. value: item.id
  440. })
  441. })
  442. this.badList = temp
  443. console.log(this.badList);
  444. }) */
  445. },
  446. handleSelect() {
  447. uni.navigateTo({
  448. url: '/pages/search/search'
  449. })
  450. },
  451. // 是否停机切换
  452. radioGroupChange(value) {
  453. this.form.needStop = value
  454. },
  455. handleSubmit() {
  456. const params = {
  457. content: this.form.content,
  458. actualUser: this.form.actualUser,
  459. needStop: this.form.needStop,
  460. sbId: this.form.sbId,
  461. sbName: this.form.sbName,
  462. sbCph: this.form.sbCph,
  463. category: this.form.category ? Number(this.form.category) : null,
  464. level: this.form.levelValue ? Number(this.form.levelValue) : null,
  465. repairErrorTypeId: this.form.repairErrorTypeId || null,
  466. limitDate: this.form.limitDate || null,
  467. limitHours: this.form.limitHours || null,
  468. // 与 PC 端 BaseForm 一致:提交当前登录人部门
  469. deptId: this.userInfo ? this.userInfo.deptId : null,
  470. applicationFileList: this.imagesList
  471. }
  472. // this.form.photo = a.join(',');
  473. var that = this
  474. this.$refs.uForm.validate(valid => {
  475. if (valid) {
  476. this.$Http.addRepairApplicationForm(params).then(res => {
  477. const sbId = that.form.sbId
  478. that.resetForm()
  479. uni.showToast({
  480. icon: 'none',
  481. title: '报修单已提交!',
  482. duration: 2000
  483. })
  484. setTimeout(function () {
  485. uni.navigateTo({
  486. url: '/pages/equipment-detail/equipment-detail?detailId=' + sbId
  487. })
  488. }, 2000)
  489. })
  490. }
  491. })
  492. },
  493. // 报修提交成功后清除表单数据
  494. resetForm() {
  495. this.form = {
  496. badType: '',
  497. running: '',
  498. sbName: '',
  499. sbCph: '',
  500. bianhao: '',
  501. halt: '',
  502. repair: '',
  503. remarks: '',
  504. actualUser: this.userInfo ? this.userInfo.realName : '',
  505. content: '',
  506. repairErrorTypeId: '',
  507. photo: '',
  508. level: '',
  509. sbId: '',
  510. needStop: 0,
  511. levelValue: '',
  512. source: '',
  513. limitDate: '',
  514. limitHours: ''
  515. }
  516. this.category = ''
  517. this.imagesList = []
  518. this.fileList = []
  519. },
  520. // 紧急等级
  521. levelSubmit(data) {
  522. this.form.level = data[0].label
  523. this.form.levelValue = data[0].value
  524. },
  525. // 选择设备
  526. runningSubmit(data) {
  527. console.log(data)
  528. this.form.sbId = data.value
  529. this.$Http
  530. .fetchSbInfo({
  531. id: data.value
  532. })
  533. .then(res => {
  534. this.form.bianhao = res.data.no
  535. this.form.sbName = res.data.name
  536. this.form.sbCph = res.data.cph
  537. })
  538. this.form.running = data.label
  539. },
  540. // 是否
  541. haltSubmit(data) {
  542. this.form.halt = data[0].label
  543. this.form.needStop = data[0].value
  544. },
  545. repairSubmit(data) {
  546. this.form.repair = data[0].label
  547. this.form.source = data[0].value
  548. },
  549. // 删除成功
  550. uploadRemove(index, lists, name) {
  551. this.fileList = lists
  552. this.imagesList.splice(index, 1)
  553. console.log(this.imagesList)
  554. },
  555. // 上传成功
  556. uploadSuccess(data, index, lists, name) {
  557. this.fileList = lists
  558. this.imagesList.push(data.data)
  559. console.log(this.imagesList)
  560. }
  561. // initSb() {
  562. // this.$Http
  563. // .getSbInfoPage({
  564. // pageNum: 1,
  565. // pageSize: 1000,
  566. // filter: 0,
  567. // })
  568. // .then((res) => {
  569. // let data = res.data.rows;
  570. // console.log(data);
  571. // data.forEach((item) => {
  572. // this.runningList.push({
  573. // label: item.nameModel,
  574. // value: item.id,
  575. // });
  576. // });
  577. // });
  578. // },
  579. }
  580. }
  581. </script>
  582. <style lang="less">
  583. .footer {
  584. bottom: 0;
  585. left: 0;
  586. right: 0;
  587. background-color: #fff;
  588. z-index: 10000;
  589. border-top: 1rpx solid #f4f4f4;
  590. height: 100rpx;
  591. .common {
  592. padding: 15rpx 200rpx;
  593. border-radius: 30rpx;
  594. background-color: #0082ff;
  595. color: #fff;
  596. }
  597. }
  598. </style>