middle.vue 20 KB

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