middle.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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-form-item>
  9. <common-popup :list="runningList" @select="runningSubmit" ref="popup" />
  10. <view class="main-color-text f-size-32 f-weight-6 mt-2">基本信息</view>
  11. <u-form-item label="设备新号" required :label-width="150">
  12. <u-input v-model="form.no" @blur="sbNoBlur($event)" />
  13. </u-form-item>
  14. <u-form-item label="设备名称" :label-width="150">
  15. <u-input v-model="form.sbName" disabled />
  16. </u-form-item>
  17. <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
  18. <u-input v-model="form.sbCph" :cursor-spacing="cursorSpacing" />
  19. </u-form-item>
  20. <u-form-item label="报修人" required :label-width="150">
  21. <u-input v-model="form.actualUser" />
  22. </u-form-item>
  23. <!-- <u-form-item label="工单类别" required prop="category" :label-width="150">
  24. <u-input v-model="category" disabled @click="badState = true" type="select" />
  25. <u-select v-model="badState" :list="categoryMap" @confirm="badSubmit"></u-select>
  26. </u-form-item> -->
  27. <view class="main-color-text f-size-32 f-weight-6 mt-2">报修信息</view>
  28. <!-- <u-form-item
  29. label="是否停机"
  30. required
  31. prop="halt"
  32. :label-width="150"
  33. >
  34. <u-input
  35. v-model="form.halt"
  36. disabled
  37. @click="haltState = true"
  38. placeholder="请选择是否停机"
  39. type="select"
  40. />
  41. <u-select
  42. v-model="haltState"
  43. :list="haltList"
  44. @confirm="haltSubmit"
  45. :default-value="haltDefaultValue"
  46. ></u-select>
  47. </u-form-item>-->
  48. <!-- <u-form-item
  49. label="报修来源"
  50. prop="repair"
  51. :label-width="150"
  52. >
  53. <u-input
  54. v-model="form.repair"
  55. disabled
  56. @click="repairState = true"
  57. placeholder="请选择报修来源"
  58. type="select"
  59. />
  60. <u-select
  61. v-model="repairState"
  62. :list="repairList"
  63. @confirm="repairSubmit"
  64. ></u-select>
  65. </u-form-item>-->
  66. <!-- <u-form-item
  67. label="紧急等级"
  68. prop="level"
  69. required
  70. :label-width="150"
  71. >
  72. <u-input
  73. v-model="form.level"
  74. disabled
  75. @click="levelState = true"
  76. placeholder="请选择紧急等级"
  77. type="select"
  78. />
  79. <u-select
  80. v-model="levelState"
  81. :list="levelList"
  82. @confirm="levelSubmit"
  83. ></u-select>
  84. </u-form-item>-->
  85. <!-- <u-form-item
  86. label="故障类别"
  87. required
  88. prop="badType"
  89. :label-width="150"
  90. >
  91. <u-input
  92. v-model="form.badType"
  93. disabled
  94. @click="badState = true"
  95. type="select"
  96. />
  97. <u-select
  98. v-model="badState"
  99. :list="badList"
  100. @confirm="badSubmit"
  101. ></u-select>
  102. </u-form-item>-->
  103. <u-form-item label="故障描述" :label-width="150">
  104. <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
  105. </u-form-item>
  106. <u-form-item label="上传图片" :label-width="150">
  107. <u-upload width="180" height="180" max-count="6" :action="action" :file-list="fileList"
  108. @on-success="uploadSuccess" @on-remove="uploadRemove" :header="header"></u-upload>
  109. </u-form-item>
  110. </u-form>
  111. <view class="d-flex j-around a-center footer">
  112. <view class="main-color-bg text-color-white common" @tap="handleSubmit">提交</view>
  113. </view>
  114. </view>
  115. <u-tabbar :list="tabbar" :mid-button="true" active-color="#0082ff"></u-tabbar>
  116. </view>
  117. </template>
  118. <script>
  119. export default {
  120. data() {
  121. return {
  122. form: {
  123. badType: '',
  124. running: '',
  125. sbName: '',
  126. actualUser: '',
  127. no: '',
  128. halt: '',
  129. sbCph: '',
  130. repair: '',
  131. remarks: '',
  132. content: '',
  133. userId: '',
  134. repairErrorTypeId: '',
  135. photo: '',
  136. level: '',
  137. // 传入的
  138. sbId: '',
  139. needStop: '',
  140. levelValue: '',
  141. source: ''
  142. },
  143. badState: false,
  144. badList: [],
  145. runningState: false, // 设备选择
  146. runningList: [],
  147. haltState: false, // 是否停机
  148. haltList: [],
  149. repairState: false, // 报修来源
  150. repairList: [],
  151. levelState: false,
  152. levelList: [],
  153. imagesList: [],
  154. action: this.$BaseTool.UserUtil.getUploadUrl(),
  155. // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
  156. header: {
  157. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  158. },
  159. fileList: [],
  160. sourceMap: {},
  161. levelMap: {},
  162. statusMap: {},
  163. needStopMap: {},
  164. categoryMap: [],
  165. category: '',
  166. haltDefaultValue: [0],
  167. rules: {
  168. running: [
  169. {
  170. required: true,
  171. message: '请选择设备',
  172. trigger: ['blur', 'change']
  173. }
  174. ],
  175. halt: [
  176. {
  177. required: true,
  178. message: '请选择是否停机',
  179. trigger: ['blur', 'change']
  180. }
  181. ],
  182. repair: [
  183. {
  184. required: true,
  185. message: '请选择报修来源',
  186. trigger: ['blur', 'change']
  187. }
  188. ],
  189. level: [
  190. {
  191. required: true,
  192. message: '请选择紧急等级',
  193. trigger: ['blur', 'change']
  194. }
  195. ],
  196. category: [
  197. {
  198. required: true,
  199. message: '请选择工单类别',
  200. trigger: ['blur', 'change']
  201. }
  202. ],
  203. sbCph: [
  204. {
  205. required: true,
  206. message: '请填写设备使用位置',
  207. trigger: ['blur', 'change']
  208. }
  209. ],
  210. content: [
  211. {
  212. required: true,
  213. message: '请输入问题描述',
  214. trigger: ['blur', 'change']
  215. }
  216. ]
  217. },
  218. // #ifdef MP-WEIXIN
  219. cursorSpacing: 50,
  220. // #endif
  221. // #ifndef MP-WEIXIN
  222. cursorSpacing: 0,
  223. // #endif
  224. sbBackId: '',
  225. address: '',
  226. tabbar: [
  227. {
  228. iconPath: '/static/tabars/home.png',
  229. pagePath: '/pages/home/home',
  230. selectedIconPath: '/static/tabars/home_s.png',
  231. text: '首页'
  232. },
  233. {
  234. iconPath: '/static/tabars/order.png',
  235. pagePath: '/pages/operate/operate',
  236. selectedIconPath: '/static/tabars/order_s.png',
  237. text: '功能'
  238. },
  239. {
  240. iconPath: '/static/tabars/publish.png',
  241. pagePath: '/pages/middle/middle',
  242. selectedIconPath: '/static/tabars/publish.png',
  243. text: '报修',
  244. midButton: true
  245. },
  246. {
  247. iconPath: '/static/tabars/tiding.png',
  248. pagePath: '/pages/tidings/tidings',
  249. selectedIconPath: '/static/tabars/tiding_s.png',
  250. text: '消息'
  251. },
  252. {
  253. iconPath: '/static/tabars/mine.png',
  254. pagePath: '/pages/my/my',
  255. selectedIconPath: '/static/tabars/mine_s.png',
  256. text: '我的'
  257. }
  258. ]
  259. }
  260. },
  261. onShow() {
  262. console.log(this.action)
  263. const pages = getCurrentPages()
  264. const currPage = pages[pages.length - 1]
  265. this.sbBackId = currPage.sbBackId
  266. if (this.sbBackId) {
  267. this.$Http
  268. .fetchSbInfo({
  269. id: this.sbBackId
  270. })
  271. .then(res => {
  272. this.form.no = res.data.no
  273. this.form.sbName = res.data.name
  274. this.form.running = res.data.name
  275. this.form.sbCph = res.data.cph
  276. this.form.sbId = this.sbBackId
  277. })
  278. }
  279. },
  280. onLoad(options) {
  281. if (options && options.detailId) {
  282. this.$Http
  283. .fetchSbInfo({
  284. id: options.detailId
  285. })
  286. .then(res => {
  287. this.form.no = res.data.no
  288. this.form.sbName = res.data.name
  289. this.form.running = res.data.name
  290. this.form.sbCph = res.data.cph
  291. this.form.sbId = options.detailId
  292. })
  293. }
  294. this.sourceMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  295. const categoryMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  296. for (const key in categoryMap) {
  297. this.categoryMap.push({
  298. label: categoryMap[key],
  299. value: key
  300. })
  301. }
  302. for (const key in this.sourceMap) {
  303. this.repairList.push({
  304. label: this.sourceMap[key],
  305. value: key
  306. })
  307. }
  308. this.form.repair = this.repairList[0].label
  309. this.form.source = this.repairList[0].value
  310. this.levelMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  311. for (const key in this.levelMap) {
  312. this.levelList.push({
  313. label: this.levelMap[key],
  314. value: key
  315. })
  316. }
  317. this.form.level = this.levelList[0].label
  318. this.form.levelValue = this.levelList[0].value
  319. this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  320. this.needStopMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.YES_NO)
  321. for (const key in this.needStopMap) {
  322. this.haltList.push({
  323. label: this.needStopMap[key],
  324. value: key
  325. })
  326. }
  327. this.form.halt = this.haltList[this.haltDefaultValue].label
  328. this.form.needStop = this.haltList[this.haltDefaultValue].value
  329. this.getType()
  330. // 获取设备数据
  331. // this.initSb();
  332. },
  333. onReady() {
  334. this.$refs.uForm.setRules(this.rules)
  335. },
  336. methods: {
  337. //
  338. confirm(e) {
  339. console.log(e)
  340. this.address = ''
  341. for (let i = 0; i < e.length; i++) {
  342. this.address += e[i].label
  343. }
  344. },
  345. badSubmit(data) {
  346. this.category = data[0].label
  347. this.form.category = data[0].value
  348. },
  349. getType() {
  350. this.$Http
  351. .fetchErrorTypeTree({
  352. id: this.detailId
  353. })
  354. .then(res => {
  355. console.log(res.data)
  356. const temp = []
  357. res.data.forEach(item => {
  358. temp.push({
  359. label: item.title,
  360. value: item.id
  361. })
  362. })
  363. this.badList = temp
  364. console.log(this.badList)
  365. })
  366. },
  367. handleSelect() {
  368. uni.navigateTo({
  369. url: '/pages/search/search'
  370. })
  371. },
  372. handleSubmit() {
  373. if (this.form.sbId === null || this.form.sbId === '') {
  374. this.$Message.toast('请先输入设备新号')
  375. return
  376. }
  377. const params = {
  378. content: this.form.content,
  379. remark: this.form.remarks,
  380. level: this.form.levelValue,
  381. needStop: this.form.needStop,
  382. sbId: this.form.sbId,
  383. sbName: this.form.sbName,
  384. sbCph: this.form.sbCph,
  385. repairErrorTypeId: this.form.repairErrorTypeId,
  386. source: this.form.source,
  387. category: this.form.category,
  388. applicationFileList: this.imagesList
  389. }
  390. console.log(params)
  391. const a = this.imagesList.map(item => {
  392. return item.url
  393. })
  394. console.log(a)
  395. // this.form.photo = a.join(',');
  396. this.$refs.uForm.validate(valid => {
  397. if (valid) {
  398. this.$Http.addRepairApplicationForm(params).then(res => {
  399. uni.navigateTo({
  400. url: '/pages/repair/repair'
  401. })
  402. })
  403. }
  404. })
  405. },
  406. // 紧急等级
  407. levelSubmit(data) {
  408. this.form.level = data[0].label
  409. this.form.levelValue = data[0].value
  410. },
  411. // 选择设备
  412. runningSubmit(data) {
  413. console.log(data)
  414. this.form.sbId = data.value
  415. this.$Http
  416. .fetchSbInfo({
  417. id: data.value
  418. })
  419. .then(res => {
  420. this.form.sbNo = res.data.no
  421. this.form.sbName = res.data.name
  422. })
  423. this.form.running = data.label
  424. },
  425. // 是否
  426. haltSubmit(data) {
  427. this.form.halt = data[0].label
  428. this.form.needStop = data[0].value
  429. },
  430. repairSubmit(data) {
  431. this.form.repair = data[0].label
  432. this.form.source = data[0].value
  433. },
  434. // 删除成功
  435. uploadRemove(index, lists, name) {
  436. this.fileList = lists
  437. this.imagesList.splice(index, 1)
  438. console.log(this.imagesList)
  439. },
  440. // 上传成功
  441. uploadSuccess(data, index, lists, name) {
  442. this.fileList = lists
  443. this.imagesList.push(data.data)
  444. console.log(this.imagesList)
  445. },
  446. sbNoBlur(sbNo) {
  447. if (sbNo == null || sbNo === '') {
  448. this.$Message.toast('请输入设备新号')
  449. return
  450. }
  451. this.form.no = sbNo
  452. this.$Http
  453. .fetchSbInfoByModel({
  454. no: sbNo
  455. })
  456. .then(res => {
  457. if (res.data == null) {
  458. this.$Message.toast('找不到对应新号的设备,请重新输入')
  459. } else {
  460. this.form.sbId = res.data.id
  461. this.form.sbName = res.data.name
  462. }
  463. })
  464. }
  465. // initSb() {
  466. // this.$Http
  467. // .getSbInfoPage({
  468. // pageNum: 1,
  469. // pageSize: 1000,
  470. // filter: 0,
  471. // })
  472. // .then((res) => {
  473. // let data = res.data.rows;
  474. // console.log(data);
  475. // data.forEach((item) => {
  476. // this.runningList.push({
  477. // label: item.nameModel,
  478. // value: item.id,
  479. // });
  480. // });
  481. // });
  482. // },
  483. }
  484. }
  485. </script>
  486. <style lang="less">
  487. .footer {
  488. bottom: 150rpx;
  489. left: 0;
  490. right: 0;
  491. z-index: 10000;
  492. border-top: 1rpx solid #f4f4f4;
  493. height: 100rpx;
  494. .common {
  495. padding: 15rpx 200rpx;
  496. border-radius: 30rpx;
  497. background-color: #0082ff;
  498. color: #fff;
  499. }
  500. }
  501. </style>