middle.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  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. // 重复报修检查:该设备存在未完结报修单时需先确认再提交(允许一台设备多个报修单)
  508. this.checkDuplicateThenAdd(params)
  509. }
  510. })
  511. },
  512. // 提交前检查该设备是否存在未完结报修单,存在则弹确认框,确认后仍允许提交
  513. checkDuplicateThenAdd(params) {
  514. var that = this
  515. this.$Http.queryUncompletedRepairs({ sbId: params.sbId }).then(res => {
  516. const list = (res && res.data) || []
  517. if (list.length === 0) {
  518. that.doAddRepair(params)
  519. return
  520. }
  521. const first = list[0]
  522. const name = params.sbName || '该设备'
  523. // 展示最新一笔未完结报修单的状态与报修内容,内容过长截断
  524. const desc = (first.content || '').length > 30 ? `${first.content.slice(0, 30)}…` : first.content || ''
  525. const detail = `${first.no} ${first.statusLabel || ''}${desc ? ',内容:' + desc : ''}`
  526. uni.showModal({
  527. title: '重复报修提醒',
  528. content: `【${name}】已有 ${list.length} 个未完结报修单(最新:${detail}),是否继续提交新报修单?`,
  529. confirmText: '继续提交',
  530. cancelText: '取消',
  531. success: (r) => {
  532. if (r.confirm) {
  533. that.doAddRepair(params)
  534. }
  535. }
  536. })
  537. })
  538. },
  539. doAddRepair(params) {
  540. this.$Http.addRepairApplicationForm(params).then(res => {
  541. this.resetForm()
  542. uni.navigateTo({
  543. url: '/pages/repair/repair'
  544. })
  545. })
  546. },
  547. // 报修提交成功后清除表单数据
  548. resetForm() {
  549. this.form = {
  550. badType: '',
  551. running: '',
  552. sbName: '',
  553. sbCph: '',
  554. bianhao: '',
  555. halt: '',
  556. repair: '',
  557. remarks: '',
  558. actualUser: this.userInfo ? this.userInfo.realName : '',
  559. content: '',
  560. repairErrorTypeId: '',
  561. photo: '',
  562. level: '',
  563. sbId: '',
  564. needStop: 0,
  565. levelValue: '',
  566. source: '',
  567. limitDate: '',
  568. limitHours: ''
  569. }
  570. this.category = ''
  571. this.imagesList = []
  572. this.fileList = []
  573. },
  574. // 紧急等级
  575. levelSubmit(data) {
  576. this.form.level = data[0].label
  577. this.form.levelValue = data[0].value
  578. },
  579. // 选择设备
  580. runningSubmit(data) {
  581. console.log(data)
  582. this.form.sbId = data.value
  583. this.$Http
  584. .fetchSbInfo({
  585. id: data.value
  586. })
  587. .then(res => {
  588. this.form.bianhao = res.data.no
  589. this.form.sbName = res.data.name
  590. this.form.sbCph = res.data.cph
  591. })
  592. this.form.running = data.label
  593. },
  594. // 是否
  595. haltSubmit(data) {
  596. this.form.halt = data[0].label
  597. this.form.needStop = data[0].value
  598. },
  599. repairSubmit(data) {
  600. this.form.repair = data[0].label
  601. this.form.source = data[0].value
  602. },
  603. // 删除成功
  604. uploadRemove(index, lists, name) {
  605. this.fileList = lists
  606. this.imagesList.splice(index, 1)
  607. console.log(this.imagesList)
  608. },
  609. // 上传成功
  610. uploadSuccess(data, index, lists, name) {
  611. this.fileList = lists
  612. this.imagesList.push(data.data)
  613. console.log(this.imagesList)
  614. },
  615. sbNoBlur(sbNo) {
  616. if (sbNo == null || sbNo === '') {
  617. this.$Message.toast('请输入设备新号')
  618. return
  619. }
  620. this.form.no = sbNo
  621. this.$Http
  622. .fetchSbInfoByModel({
  623. no: sbNo
  624. })
  625. .then(res => {
  626. if (res.data == null) {
  627. this.$Message.toast('找不到对应新号的设备,请重新输入')
  628. } else {
  629. this.form.sbId = res.data.id
  630. this.form.sbName = res.data.name
  631. }
  632. })
  633. }
  634. // initSb() {
  635. // this.$Http
  636. // .getSbInfoPage({
  637. // pageNum: 1,
  638. // pageSize: 1000,
  639. // filter: 0,
  640. // })
  641. // .then((res) => {
  642. // let data = res.data.rows;
  643. // console.log(data);
  644. // data.forEach((item) => {
  645. // this.runningList.push({
  646. // label: item.nameModel,
  647. // value: item.id,
  648. // });
  649. // });
  650. // });
  651. // },
  652. }
  653. }
  654. </script>
  655. <style lang="less">
  656. .footer {
  657. bottom: 150rpx;
  658. left: 0;
  659. right: 0;
  660. z-index: 10000;
  661. border-top: 1rpx solid #f4f4f4;
  662. height: 100rpx;
  663. .common {
  664. padding: 15rpx 200rpx;
  665. border-radius: 30rpx;
  666. background-color: #0082ff;
  667. color: #fff;
  668. }
  669. }
  670. </style>