repair-add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. <!--
  39. <u-form-item label="紧急等级" prop="level" required :label-width="150">
  40. <u-input
  41. v-model="form.level"
  42. disabled
  43. @click="levelState = true"
  44. placeholder="请选择紧急等级"
  45. type="select"
  46. />
  47. <u-select
  48. v-model="levelState"
  49. :list="levelList"
  50. @confirm="levelSubmit"
  51. ></u-select>
  52. </u-form-item>
  53. <u-form-item label="故障类别" required prop="badType" :label-width="150">
  54. <u-input v-model="form.badType" disabled @click="badState = true" type="select" />
  55. <u-select v-model="badState" :list="badList" @confirm="badSubmit"></u-select>
  56. </u-form-item>-->
  57. <!-- <u-form-item
  58. label="工单类别"
  59. required
  60. prop="category"
  61. :label-width="150"
  62. >
  63. <u-input
  64. v-model="category"
  65. disabled
  66. @click="badState = true"
  67. type="select"
  68. />
  69. <u-select
  70. v-model="badState"
  71. :list="categoryMap"
  72. @confirm="badSubmit"
  73. ></u-select>
  74. </u-form-item> -->
  75. <u-form-item label="使用位置" prop="sbCph" required :label-width="150">
  76. <tree-select v-model="form.sbCph" valueName="title" :data="sbPositionData"></tree-select>
  77. </u-form-item>
  78. <u-form-item label="是否停机" required prop="needStop" :label-width="150">
  79. <!-- <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
  80. type="select" /> -->
  81. <u-radio-group v-model="form.needStop" @change="radioGroupChange">
  82. <u-radio :name="0">
  83. </u-radio>
  84. <u-radio :name="1">
  85. </u-radio>
  86. </u-radio-group>
  87. </u-form-item>
  88. <u-form-item label="报修人" prop="actualUser" required :label-width="150">
  89. <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
  90. </u-form-item>
  91. <u-form-item label="故障描述" prop="content" required :label-width="150">
  92. <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
  93. </u-form-item>
  94. <!-- <u-select v-model="aShow" mode="mutil-column-auto" :list="aList" @confirm="confirm"></u-select>-->
  95. <u-form-item label="上传图片" :label-width="150">
  96. <u-upload width="180" height="180" max-count="6" :action="action" :file-list="fileList"
  97. @on-success="uploadSuccess" @on-remove="uploadRemove"></u-upload>
  98. </u-form-item>
  99. </u-form>
  100. <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
  101. <view class="p-fixed d-flex j-around a-center footer">
  102. <view class="main-color-bg text-color-white common" @tap="handleSubmit">提交</view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. return {
  111. form: {
  112. badType: '',
  113. running: '',
  114. sbName: '',
  115. sbCph: '',
  116. bianhao: '',
  117. halt: '',
  118. repair: '',
  119. remarks: '',
  120. actualUser: '',
  121. content: '',
  122. repairErrorTypeId: '',
  123. photo: '',
  124. level: '',
  125. // 传入的
  126. sbId: '',
  127. needStop: 0,
  128. levelValue: '',
  129. source: ''
  130. },
  131. category: '',
  132. badState: false,
  133. badList: [],
  134. runningState: false, // 设备选择
  135. runningList: [],
  136. haltState: false, // 是否停机
  137. haltList: [],
  138. repairState: false, // 报修来源
  139. repairList: [],
  140. levelState: false,
  141. levelList: [],
  142. imagesList: [],
  143. action: this.$BaseTool.UserUtil.getUploadUrlIgnores(),
  144. // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
  145. /* header: {
  146. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  147. }, */
  148. fileList: [],
  149. sourceMap: {},
  150. levelMap: {},
  151. statusMap: {},
  152. needStopMap: {},
  153. categoryMap: [],
  154. haltDefaultValue: [0],
  155. rules: {
  156. running: [
  157. {
  158. required: true,
  159. message: '请选择设备',
  160. trigger: ['blur', 'change']
  161. }
  162. ],
  163. category: [
  164. {
  165. required: true,
  166. message: '请选择工单类别',
  167. trigger: ['blur', 'change']
  168. }
  169. ],
  170. halt: [
  171. {
  172. required: true,
  173. message: '请选择是否停机',
  174. trigger: ['blur', 'change']
  175. }
  176. ],
  177. repair: [
  178. {
  179. required: true,
  180. message: '请选择报修来源',
  181. trigger: ['blur', 'change']
  182. }
  183. ],
  184. actualUser: [
  185. {
  186. required: true,
  187. message: '请填写报修人',
  188. trigger: ['blur', 'change']
  189. }
  190. ],
  191. sbCph: [
  192. {
  193. required: true,
  194. message: '请填写设备使用位置',
  195. trigger: ['blur', 'change']
  196. }
  197. ],
  198. level: [
  199. {
  200. required: true,
  201. message: '请选择紧急等级',
  202. trigger: ['blur', 'change']
  203. }
  204. ],
  205. content: [
  206. {
  207. required: true,
  208. message: '请输入问题描述',
  209. trigger: ['blur', 'change']
  210. }
  211. ]
  212. },
  213. // #ifdef MP-WEIXIN
  214. cursorSpacing: 50,
  215. // #endif
  216. // #ifndef MP-WEIXIN
  217. cursorSpacing: 0,
  218. // #endif
  219. sbBackId: '',
  220. aShow: false,
  221. address: '',
  222. sbPositionData: [],
  223. sbId: null,
  224. aList: []
  225. }
  226. },
  227. onShow() {
  228. this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
  229. if (this.userInfo) {
  230. this.form.actualUser = this.userInfo.realName
  231. }
  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. if (options && options.detailId) {
  252. this.sbId = options.detailId
  253. this.$Http
  254. .fetchSbInfoIgnores({
  255. id: options.detailId
  256. })
  257. .then(res => {
  258. this.form.bianhao = res.data.no
  259. this.form.sbName = res.data.name
  260. this.form.running = res.data.name
  261. this.form.sbId = options.detailId
  262. this.form.sbCph = res.data.cph
  263. })
  264. }
  265. // this.sourceMap = this.$DictCache.getLabelByValueMapByType(
  266. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
  267. // );
  268. // for (const key in this.sourceMap) {
  269. // this.repairList.push({
  270. // label: this.sourceMap[key],
  271. // value: key
  272. // });
  273. // }
  274. // this.form.repair = this.repairList[0].label;
  275. // this.form.source = this.repairList[0].value;
  276. // this.levelMap = this.$DictCache.getLabelByValueMapByType(
  277. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
  278. // );
  279. // for (const key in this.levelMap) {
  280. // this.levelList.push({
  281. // label: this.levelMap[key],
  282. // value: key
  283. // });
  284. // }
  285. // this.form.level = this.levelList[0].label;
  286. // this.form.levelValue = this.levelList[0].value;
  287. // this.statusMap = this.$DictCache.getLabelByValueMapByType(
  288. // this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
  289. // );
  290. console.log(22)
  291. this.$Http
  292. .getDictType({
  293. type: this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  294. })
  295. .then(res => {
  296. this.categoryMap = res.data
  297. })
  298. this.$Http
  299. .getSbPositionTree().then(res => {
  300. this.sbPositionData = 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. // 是否停机切换
  367. radioGroupChange(value) {
  368. this.form.needStop = value
  369. },
  370. handleSubmit() {
  371. const params = {
  372. content: this.form.content,
  373. actualUser: this.form.actualUser,
  374. needStop: this.form.needStop,
  375. sbId: this.form.sbId,
  376. sbName: this.form.sbName,
  377. sbCph: this.form.sbCph,
  378. applicationFileList: this.imagesList
  379. }
  380. // this.form.photo = a.join(',');
  381. var that = this
  382. this.$refs.uForm.validate(valid => {
  383. if (valid) {
  384. this.$Http.addRepairApplicationForm(params).then(res => {
  385. const sbId = that.form.sbId
  386. that.resetForm()
  387. uni.showToast({
  388. icon: 'none',
  389. title: '报修单已提交!',
  390. duration: 2000
  391. })
  392. setTimeout(function () {
  393. uni.navigateTo({
  394. url: '/pages/equipment-detail/equipment-detail?detailId=' + sbId
  395. })
  396. }, 2000)
  397. })
  398. }
  399. })
  400. },
  401. // 报修提交成功后清除表单数据
  402. resetForm() {
  403. this.form = {
  404. badType: '',
  405. running: '',
  406. sbName: '',
  407. sbCph: '',
  408. bianhao: '',
  409. halt: '',
  410. repair: '',
  411. remarks: '',
  412. actualUser: this.userInfo ? this.userInfo.realName : '',
  413. content: '',
  414. repairErrorTypeId: '',
  415. photo: '',
  416. level: '',
  417. sbId: '',
  418. needStop: 0,
  419. levelValue: '',
  420. source: ''
  421. }
  422. this.imagesList = []
  423. this.fileList = []
  424. },
  425. // 紧急等级
  426. levelSubmit(data) {
  427. this.form.level = data[0].label
  428. this.form.levelValue = data[0].value
  429. },
  430. // 选择设备
  431. runningSubmit(data) {
  432. console.log(data)
  433. this.form.sbId = data.value
  434. this.$Http
  435. .fetchSbInfo({
  436. id: data.value
  437. })
  438. .then(res => {
  439. this.form.bianhao = res.data.no
  440. this.form.sbName = res.data.name
  441. this.form.sbCph = res.data.cph
  442. })
  443. this.form.running = data.label
  444. },
  445. // 是否
  446. haltSubmit(data) {
  447. this.form.halt = data[0].label
  448. this.form.needStop = data[0].value
  449. },
  450. repairSubmit(data) {
  451. this.form.repair = data[0].label
  452. this.form.source = data[0].value
  453. },
  454. // 删除成功
  455. uploadRemove(index, lists, name) {
  456. this.fileList = lists
  457. this.imagesList.splice(index, 1)
  458. console.log(this.imagesList)
  459. },
  460. // 上传成功
  461. uploadSuccess(data, index, lists, name) {
  462. this.fileList = lists
  463. this.imagesList.push(data.data)
  464. console.log(this.imagesList)
  465. }
  466. // initSb() {
  467. // this.$Http
  468. // .getSbInfoPage({
  469. // pageNum: 1,
  470. // pageSize: 1000,
  471. // filter: 0,
  472. // })
  473. // .then((res) => {
  474. // let data = res.data.rows;
  475. // console.log(data);
  476. // data.forEach((item) => {
  477. // this.runningList.push({
  478. // label: item.nameModel,
  479. // value: item.id,
  480. // });
  481. // });
  482. // });
  483. // },
  484. }
  485. }
  486. </script>
  487. <style lang="less">
  488. .footer {
  489. bottom: 0;
  490. left: 0;
  491. right: 0;
  492. background-color: #fff;
  493. z-index: 10000;
  494. border-top: 1rpx solid #f4f4f4;
  495. height: 100rpx;
  496. .common {
  497. padding: 15rpx 200rpx;
  498. border-radius: 30rpx;
  499. background-color: #0082ff;
  500. color: #fff;
  501. }
  502. }
  503. </style>