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