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