repair-add.vue 17 KB

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