repair-add.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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="故障类型" 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. },
  250. // #ifdef MP-WEIXIN
  251. cursorSpacing: 50,
  252. // #endif
  253. // #ifndef MP-WEIXIN
  254. cursorSpacing: 0,
  255. // #endif
  256. sbBackId: '',
  257. aShow: false,
  258. address: '',
  259. sbPositionData: [],
  260. sbId: null,
  261. aList: []
  262. }
  263. },
  264. onShow() {
  265. this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
  266. if (this.userInfo) {
  267. this.form.actualUser = this.userInfo.realName
  268. }
  269. const pages = getCurrentPages()
  270. const currPage = pages[pages.length - 1]
  271. this.sbBackId = currPage.sbBackId
  272. this.sbId = currPage.sbBackId
  273. if (this.sbBackId) {
  274. this.$Http
  275. .fetchSbInfoIgnores({
  276. id: this.sbBackId
  277. })
  278. .then(res => {
  279. this.form.bianhao = res.data.no
  280. this.form.sbName = res.data.name
  281. this.form.sbCph = res.data.positionName
  282. this.form.running = res.data.name
  283. this.form.sbId = this.sbBackId
  284. })
  285. }
  286. },
  287. onLoad(options) {
  288. if (options && options.detailId) {
  289. this.sbId = options.detailId
  290. this.$Http
  291. .fetchSbInfoIgnores({
  292. id: options.detailId
  293. })
  294. .then(res => {
  295. this.form.bianhao = res.data.no
  296. this.form.sbName = res.data.name
  297. this.form.running = res.data.name
  298. this.form.sbId = options.detailId
  299. this.form.sbCph = res.data.positionName
  300. })
  301. }
  302. // this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  303. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  304. // );
  305. // for (const key in this.sourceMap) {
  306. // this.repairList.push({
  307. // label: this.sourceMap[key],
  308. // value: key
  309. // });
  310. // }
  311. // this.form.repair = this.repairList[0].label;
  312. // this.form.source = this.repairList[0].value;
  313. // this.levelMap = this.$DictCache.getLabelByValueMapByType(
  314. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  315. // );
  316. // for (const key in this.levelMap) {
  317. // this.levelList.push({
  318. // label: this.levelMap[key],
  319. // value: key
  320. // });
  321. // }
  322. // this.form.level = this.levelList[0].label;
  323. // this.form.levelValue = this.levelList[0].value;
  324. // this.statusMap = this.$DictCache.getLabelByValueMapByType(
  325. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  326. // );
  327. console.log(22)
  328. // 同步 PC 端报修提交字段:工单类别、紧急程度、故障类型字典
  329. const categoryMap = this.$DictCache.getLabelByValueMapByType(
  330. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  331. )
  332. for (const key in categoryMap) {
  333. this.categoryMap.push({
  334. label: categoryMap[key],
  335. value: key
  336. })
  337. }
  338. const levelMap = this.$DictCache.getLabelByValueMapByType(
  339. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  340. )
  341. for (const key in levelMap) {
  342. this.levelList.push({
  343. label: levelMap[key],
  344. value: key
  345. })
  346. }
  347. // 紧急程度默认一级,与 PC 端默认值保持一致
  348. // if (levelMap && levelMap['1']) {
  349. // this.form.level = levelMap['1']
  350. // this.form.levelValue = '1'
  351. // }
  352. this.$Http
  353. .getDictType({
  354. type: 'REPAIR_ERROR_TYPE'
  355. })
  356. .then(res => {
  357. this.errorTypeList = (res.data || []).map(item => ({
  358. label: item.label,
  359. value: item.value
  360. }))
  361. })
  362. this.$Http
  363. .getSbPositionTree().then(res => {
  364. this.sbPositionData = res.data
  365. })
  366. // const categoryMap = this.$DictCache.getLabelByValueMapByType(
  367. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  368. // )
  369. // for (const key in categoryMap) {
  370. // this.categoryMap.push({
  371. // label: categoryMap[key],
  372. // value: key
  373. // });
  374. // }
  375. // console.log(this.categoryMap)
  376. // this.needStopMap = this.$DictCache.getLabelByValueMapByType(
  377. // this.$DictCache.TYPE.YES_NO
  378. // )
  379. // for (const key in this.needStopMap) {
  380. // this.haltList.push({
  381. // label: this.needStopMap[key],
  382. // value: key
  383. // });
  384. // }
  385. // this.form.halt = this.haltList[this.haltDefaultValue].label;
  386. // this.form.needStop = this.haltList[this.haltDefaultValue].value;
  387. this.getType()
  388. // 获取设备数据
  389. // this.initSb();
  390. },
  391. onReady() {
  392. this.$refs.uForm.setRules(this.rules)
  393. },
  394. methods: {
  395. //
  396. confirm(e) {
  397. console.log(e)
  398. this.address = ''
  399. for (let i = 0; i < e.length; i++) {
  400. this.address += e[i].label
  401. }
  402. },
  403. badSubmit(data) {
  404. this.category = data[0].label
  405. this.form.category = data[0].value
  406. },
  407. // 工单类别
  408. categorySubmit(data) {
  409. this.category = data[0].label
  410. this.form.category = data[0].value
  411. },
  412. // 故障类型
  413. errorTypeSubmit(data) {
  414. this.form.badType = data[0].label
  415. this.form.repairErrorTypeId = data[0].value
  416. },
  417. // 要求日期
  418. limitDateSubmit(e) {
  419. this.form.limitDate = `${e.year}-${e.month}-${e.day}`
  420. },
  421. getType() {
  422. /* this.$Http
  423. .fetchErrorTypeTree({
  424. id: this.detailId
  425. })
  426. .then((res) => {
  427. console.log(res.data);
  428. const temp = []
  429. res.data.forEach(item => {
  430. temp.push({
  431. label: item.title,
  432. value: item.id
  433. })
  434. })
  435. this.badList = temp
  436. console.log(this.badList);
  437. }) */
  438. },
  439. handleSelect() {
  440. uni.navigateTo({
  441. url: '/pages/search/search'
  442. })
  443. },
  444. // 是否停机切换
  445. radioGroupChange(value) {
  446. this.form.needStop = value
  447. },
  448. handleSubmit() {
  449. const params = {
  450. content: this.form.content,
  451. actualUser: this.form.actualUser,
  452. needStop: this.form.needStop,
  453. sbId: this.form.sbId,
  454. sbName: this.form.sbName,
  455. sbCph: this.form.sbCph,
  456. category: this.form.category ? Number(this.form.category) : null,
  457. level: this.form.levelValue ? Number(this.form.levelValue) : null,
  458. repairErrorTypeId: this.form.repairErrorTypeId || null,
  459. limitDate: this.form.limitDate || null,
  460. limitHours: this.form.limitHours || null,
  461. // 与 PC 端 BaseForm 一致:提交当前登录人部门
  462. deptId: this.userInfo ? this.userInfo.deptId : null,
  463. applicationFileList: this.imagesList
  464. }
  465. // this.form.photo = a.join(',');
  466. var that = this
  467. this.$refs.uForm.validate(valid => {
  468. if (valid) {
  469. this.$Http.addRepairApplicationForm(params).then(res => {
  470. const sbId = that.form.sbId
  471. that.resetForm()
  472. uni.showToast({
  473. icon: 'none',
  474. title: '报修单已提交!',
  475. duration: 2000
  476. })
  477. setTimeout(function () {
  478. uni.navigateTo({
  479. url: '/pages/equipment-detail/equipment-detail?detailId=' + sbId
  480. })
  481. }, 2000)
  482. })
  483. }
  484. })
  485. },
  486. // 报修提交成功后清除表单数据
  487. resetForm() {
  488. this.form = {
  489. badType: '',
  490. running: '',
  491. sbName: '',
  492. sbCph: '',
  493. bianhao: '',
  494. halt: '',
  495. repair: '',
  496. remarks: '',
  497. actualUser: this.userInfo ? this.userInfo.realName : '',
  498. content: '',
  499. repairErrorTypeId: '',
  500. photo: '',
  501. level: '',
  502. sbId: '',
  503. needStop: 0,
  504. levelValue: '',
  505. source: '',
  506. limitDate: '',
  507. limitHours: ''
  508. }
  509. this.category = ''
  510. this.imagesList = []
  511. this.fileList = []
  512. },
  513. // 紧急等级
  514. levelSubmit(data) {
  515. this.form.level = data[0].label
  516. this.form.levelValue = data[0].value
  517. },
  518. // 选择设备
  519. runningSubmit(data) {
  520. console.log(data)
  521. this.form.sbId = data.value
  522. this.$Http
  523. .fetchSbInfo({
  524. id: data.value
  525. })
  526. .then(res => {
  527. this.form.bianhao = res.data.no
  528. this.form.sbName = res.data.name
  529. this.form.sbCph = res.data.cph
  530. })
  531. this.form.running = data.label
  532. },
  533. // 是否
  534. haltSubmit(data) {
  535. this.form.halt = data[0].label
  536. this.form.needStop = data[0].value
  537. },
  538. repairSubmit(data) {
  539. this.form.repair = data[0].label
  540. this.form.source = data[0].value
  541. },
  542. // 删除成功
  543. uploadRemove(index, lists, name) {
  544. this.fileList = lists
  545. this.imagesList.splice(index, 1)
  546. console.log(this.imagesList)
  547. },
  548. // 上传成功
  549. uploadSuccess(data, index, lists, name) {
  550. this.fileList = lists
  551. this.imagesList.push(data.data)
  552. console.log(this.imagesList)
  553. }
  554. // initSb() {
  555. // this.$Http
  556. // .getSbInfoPage({
  557. // pageNum: 1,
  558. // pageSize: 1000,
  559. // filter: 0,
  560. // })
  561. // .then((res) => {
  562. // let data = res.data.rows;
  563. // console.log(data);
  564. // data.forEach((item) => {
  565. // this.runningList.push({
  566. // label: item.nameModel,
  567. // value: item.id,
  568. // });
  569. // });
  570. // });
  571. // },
  572. }
  573. }
  574. </script>
  575. <style lang="less">
  576. .footer {
  577. bottom: 0;
  578. left: 0;
  579. right: 0;
  580. background-color: #fff;
  581. z-index: 10000;
  582. border-top: 1rpx solid #f4f4f4;
  583. height: 100rpx;
  584. .common {
  585. padding: 15rpx 200rpx;
  586. border-radius: 30rpx;
  587. background-color: #0082ff;
  588. color: #fff;
  589. }
  590. }
  591. </style>