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