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