middle.vue 24 KB

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