middle.vue 24 KB

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