BaseForm.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="900"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-form :form="form">
  11. <a-form-item v-show="false" >
  12. <a-input v-decorator="['id']" type="hidden"/>
  13. <a-input v-decorator="['sbId']" type="hidden"/>
  14. <a-input v-decorator="['partId']" type="hidden"/>
  15. </a-form-item>
  16. <row-list :col="2">
  17. <row-item>
  18. <a-form-item
  19. label="设备名称"
  20. :labelCol="BaseTool.Constant.labelCol"
  21. :wrapperCol="BaseTool.Constant.wrapperCol"
  22. >
  23. <a-input
  24. style="width: 70%"
  25. disabled
  26. v-decorator="['sbName', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  27. <a-button style="width: 30%" type="primary" @click="handleSbSelect">选择</a-button>
  28. </a-form-item>
  29. </row-item>
  30. <row-item>
  31. <a-form-item
  32. label="机电仪位号"
  33. :labelCol="BaseTool.Constant.labelCol"
  34. :wrapperCol="BaseTool.Constant.wrapperCol"
  35. >
  36. <a-input v-decorator="['parentSbNo']" />
  37. </a-form-item>
  38. </row-item>
  39. <!-- <row-item>
  40. <a-form-item
  41. label="设备部位"
  42. :labelCol="BaseTool.Constant.labelCol"
  43. :wrapperCol="BaseTool.Constant.wrapperCol"
  44. >
  45. <a-input
  46. style="width: 70%"
  47. disabled
  48. v-decorator="['partName']" />
  49. <a-button style="width: 30%" type="primary" @click="handlePartSelect">选择</a-button>
  50. </a-form-item>
  51. </row-item>-->
  52. <!-- <row-item>
  53. <a-form-item
  54. label="委托单位"
  55. :labelCol="BaseTool.Constant.labelCol"
  56. :wrapperCol="BaseTool.Constant.wrapperCol"
  57. >
  58. <a-select v-decorator="['trustDept', {rules: [{required: true, message: '委托单位不能为空'}]}]" placeholder="请选择">
  59. <a-select-option
  60. v-for="(label,value) in trustMap"
  61. :key="value"
  62. :label="label"
  63. :value="value">{{ label }}
  64. </a-select-option>
  65. </a-select>
  66. </a-form-item>
  67. </row-item> -->
  68. <row-item>
  69. <a-form-item
  70. label="维修部门"
  71. :labelCol="BaseTool.Constant.labelCol"
  72. :wrapperCol="BaseTool.Constant.wrapperCol"
  73. >
  74. <a-select v-decorator="['repairDeptId', {rules: [{required: true, message: '维修部门不能为空'}]}]" placeholder="请选择">
  75. <a-select-option
  76. v-for="(label,value) in repairDeptMap"
  77. :key="value"
  78. :label="label"
  79. :value="value">{{ label }}
  80. </a-select-option>
  81. </a-select>
  82. </a-form-item>
  83. </row-item>
  84. <row-item>
  85. <a-form-item
  86. label="维修专业"
  87. :labelCol="BaseTool.Constant.labelCol"
  88. :wrapperCol="BaseTool.Constant.wrapperCol"
  89. >
  90. <a-tree-select
  91. tree-checkable
  92. :show-checked-strategy="SHOW_PARENT"
  93. v-decorator="['repairProfessor', {initialValue: [1], rules: [{required: true, message: '检修专业不能为空'}]}]"
  94. placeholder="请选择">
  95. <a-tree-select-node
  96. v-for="(label,value) in professorMap"
  97. :key="value"
  98. :title="label"
  99. :value="parseInt(value)">{{ label }}
  100. </a-tree-select-node>
  101. </a-tree-select>
  102. </a-form-item>
  103. </row-item>
  104. <row-item>
  105. <a-form-item
  106. label="生产装置"
  107. :labelCol="BaseTool.Constant.labelCol"
  108. :wrapperCol="BaseTool.Constant.wrapperCol"
  109. >
  110. <a-cascader
  111. :options="sbPositionList"
  112. :load-data="loadData"
  113. placeholder="请选择"
  114. change-on-select
  115. v-decorator="['sbPosition', {rules: [{required: true, message: '生产装置不能为空'}]}]"
  116. />
  117. </a-form-item>
  118. </row-item>
  119. <row-item>
  120. <a-form-item
  121. label="特殊作业类型"
  122. :labelCol="BaseTool.Constant.labelCol"
  123. :wrapperCol="BaseTool.Constant.wrapperCol"
  124. >
  125. <a-tree-select
  126. tree-checkable
  127. :show-checked-strategy="SHOW_PARENT"
  128. v-decorator="['repairType', {rules: [{required: true, message: '工作类型不能为空'}]}]"
  129. placeholder="请选择">
  130. <a-tree-select-node
  131. v-for="(label,value) in repairTypeMap"
  132. :key="value"
  133. :title="label"
  134. :value="parseInt(value)">{{ label }}
  135. </a-tree-select-node>
  136. </a-tree-select>
  137. </a-form-item>
  138. </row-item>
  139. <row-item>
  140. <a-form-item
  141. label="车间具体位置"
  142. :labelCol="BaseTool.Constant.labelCol"
  143. :wrapperCol="BaseTool.Constant.wrapperCol"
  144. >
  145. <a-input
  146. placeholder="比如:甲七车间北侧"
  147. v-decorator="['sbCph']" />
  148. </a-form-item>
  149. </row-item>
  150. <row-item>
  151. <a-form-item
  152. label="工单类别"
  153. :labelCol="BaseTool.Constant.labelCol"
  154. :wrapperCol="BaseTool.Constant.wrapperCol"
  155. >
  156. <a-select @change="changePlanFlag" v-decorator="['category', {initialValue: 2, rules: [{required: true, message: '工单类别不能为空'}]}]" placeholder="请选择">
  157. <a-select-option
  158. v-for="(label,value) in categoryMap"
  159. :key="value"
  160. :label="label"
  161. :value="parseInt(value)">{{ label }}
  162. </a-select-option>
  163. </a-select>
  164. </a-form-item>
  165. </row-item>
  166. <row-item>
  167. <a-form-item
  168. label="是否停机"
  169. :labelCol="BaseTool.Constant.labelCol"
  170. :wrapperCol="BaseTool.Constant.wrapperCol"
  171. >
  172. <a-select v-decorator="['needStop', {rules: [{required: true, message: '是否停机不能为空'}]}]" placeholder="请选择">
  173. <a-select-option
  174. v-for="(label,value) in needStopMap"
  175. :key="value"
  176. :label="label"
  177. :value="parseInt(value)">{{ label }}
  178. </a-select-option>
  179. </a-select>
  180. </a-form-item>
  181. </row-item>
  182. <row-item v-if="category === 1">
  183. <a-form-item
  184. label="计划性维修级别"
  185. :labelCol="BaseTool.Constant.labelCol"
  186. :wrapperCol="BaseTool.Constant.wrapperCol"
  187. >
  188. <a-select v-decorator="['repairPlanLevel', {rules: [{required: true, message: '计划性维修级别不能为空'}]}]" placeholder="请选择">
  189. <a-select-option
  190. v-for="value in ['大','中','小']"
  191. :key="value"
  192. :label="value"
  193. :value="value">{{ value }}
  194. </a-select-option>
  195. </a-select>
  196. </a-form-item>
  197. </row-item>
  198. <row-item v-if="category === 1">
  199. <a-form-item
  200. label="审批人"
  201. :labelCol="BaseTool.Constant.labelCol"
  202. :wrapperCol="BaseTool.Constant.wrapperCol"
  203. >
  204. <a-select v-decorator="['dispatchUserId', {rules: [{required: true, message: '审批人不能为空'}]}]" placeholder="请选择">
  205. <a-select-option
  206. v-for="({realName,userId}) in dispatchUserList"
  207. :key="userId"
  208. :label="realName"
  209. :value="userId">{{ realName }}
  210. </a-select-option>
  211. </a-select>
  212. </a-form-item>
  213. </row-item>
  214. <!-- <row-item v-show="category === 1">
  215. <a-form-item
  216. label="要求日期"
  217. :labelCol="BaseTool.Constant.labelCol"
  218. :wrapperCol="BaseTool.Constant.wrapperCol"
  219. >
  220. <a-date-picker
  221. style="width: 100%"
  222. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  223. v-decorator="['limitDate']" />
  224. </a-form-item>
  225. </row-item> -->
  226. <!-- <row-item v-show="category === 2">
  227. <a-form-item
  228. label="要求时间"
  229. :labelCol="BaseTool.Constant.labelCol"
  230. :wrapperCol="BaseTool.Constant.wrapperCol"
  231. >
  232. <a-input
  233. style="width: 100%"
  234. suffix="小时"
  235. v-decorator="['limitHours', {rules: [{required: true, message: '要求时间不能为空'}]}]" />
  236. </a-form-item>
  237. </row-item> -->
  238. <row-item>
  239. <a-form-item
  240. label="计划开始时间"
  241. :labelCol="BaseTool.Constant.labelCol"
  242. :wrapperCol="BaseTool.Constant.wrapperCol"
  243. >
  244. <a-date-picker
  245. style="width: 100%"
  246. show-time
  247. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  248. v-decorator="['planStartTime', {rules: [{required: true, message: '计划开始时间不能为空'}]}]" />
  249. </a-form-item>
  250. </row-item>
  251. <row-item>
  252. <a-form-item
  253. label="计划结束时间"
  254. :labelCol="BaseTool.Constant.labelCol"
  255. :wrapperCol="BaseTool.Constant.wrapperCol"
  256. >
  257. <a-date-picker
  258. style="width: 100%"
  259. show-time
  260. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  261. v-decorator="['planEndTime', {rules: [{required: true, message: '计划结束时间不能为空'}]}]" />
  262. </a-form-item>
  263. </row-item>
  264. <row-item v-if="category !== 1">
  265. <a-form-item
  266. label="工作优选权"
  267. :labelCol="BaseTool.Constant.labelCol"
  268. :wrapperCol="BaseTool.Constant.wrapperCol"
  269. >
  270. <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '工作优选权不能为空'}]}]" placeholder="请选择">
  271. <a-select-option
  272. v-for="(label,value) in levelMap"
  273. :key="value"
  274. :label="label"
  275. :value="parseInt(value)">{{ label }}
  276. </a-select-option>
  277. </a-select>
  278. </a-form-item>
  279. </row-item>
  280. <row-item>
  281. <a-form-item
  282. label="报修人"
  283. :labelCol="BaseTool.Constant.labelCol"
  284. :wrapperCol="BaseTool.Constant.wrapperCol"
  285. >
  286. <a-input
  287. disabled="disabled"
  288. v-decorator="['actualUser', {initialValue: userInfo.realName, rules: [{required: true, message: '报修人不能为空'}]}]"/>
  289. </a-form-item>
  290. </row-item>
  291. <!-- <row-item>
  292. <a-form-item
  293. label="紧急等级"
  294. :labelCol="BaseTool.Constant.labelCol"
  295. :wrapperCol="BaseTool.Constant.wrapperCol"
  296. >
  297. <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '紧急等级不能为空'}]}]" placeholder="请选择">
  298. <a-select-option
  299. v-for="(label,value) in levelMap"
  300. :key="value"
  301. :label="label"
  302. :value="parseInt(value)">{{ label }}
  303. </a-select-option>
  304. </a-select>
  305. </a-form-item>
  306. </row-item>
  307. <row-item>
  308. <a-form-item
  309. label="异常类别"
  310. :labelCol="BaseTool.Constant.labelCol"
  311. :wrapperCol="BaseTool.Constant.wrapperCol"
  312. >
  313. <a-tree-select
  314. style="width: 100%"
  315. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  316. :treeData="treeData"
  317. :treeNodeFilterProp="'title'"
  318. :showSearch="true"
  319. v-decorator="['repairErrorTypeId']"
  320. placeholder="请选择"
  321. >
  322. </a-tree-select>
  323. </a-form-item>
  324. </row-item>-->
  325. <row-item>
  326. <a-form-item
  327. label="报修图片"
  328. :labelCol="BaseTool.Constant.labelCol"
  329. :wrapperCol="BaseTool.Constant.wrapperCol"
  330. >
  331. <a-upload
  332. :action="uploadUrl"
  333. :multiple="true"
  334. list-type="picture"
  335. :file-list="this.defaultApplicationFileList"
  336. @change="handleApplicationFileChange"
  337. accept="image/*"
  338. :headers="headers"
  339. >
  340. <a-button> <a-icon type="upload" /> 上传图片 </a-button>
  341. </a-upload>
  342. </a-form-item>
  343. </row-item>
  344. <row-item>
  345. <a-form-item
  346. label="资料文件"
  347. :labelCol="BaseTool.Constant.labelCol"
  348. :wrapperCol="BaseTool.Constant.wrapperCol"
  349. >
  350. <a-upload
  351. :action="uploadUrl"
  352. :multiple="true"
  353. :file-list="defaultCheckFileList"
  354. @change="handleCheckFileChange"
  355. :headers="headers"
  356. >
  357. <a-button> <a-icon type="upload" /> 上传 </a-button>
  358. </a-upload>
  359. </a-form-item>
  360. </row-item>
  361. <row-item v-show="refusedFlag">
  362. <a-form-item
  363. label="驳回原因"
  364. :labelCol="BaseTool.Constant.labelCol"
  365. :wrapperCol="BaseTool.Constant.wrapperCol"
  366. >
  367. <a-input
  368. disabled="disabled"
  369. v-decorator="['remark']"/>
  370. </a-form-item>
  371. </row-item>
  372. </row-list>
  373. <row-list :col="1">
  374. <row-item v-if="false">
  375. <a-form-item
  376. label="报修状态"
  377. :labelCol="BaseTool.Constant.labelCol"
  378. :wrapperCol="BaseTool.Constant.wrapperCol"
  379. >
  380. <a-select disabled v-decorator="['status', {initialValue: DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED,rules: [{required: true, message: '报修状态不能为空'}]}]" placeholder="请选择">
  381. <a-select-option
  382. v-for="(label,value) in statusMap"
  383. :key="value"
  384. :label="label"
  385. :value="parseInt(value)">{{ label }}
  386. </a-select-option>
  387. </a-select>
  388. </a-form-item>
  389. </row-item>
  390. <!-- <row-item>
  391. <a-form-item
  392. label="故障描述"
  393. :labelCol="BaseTool.Constant.labelCol2"
  394. :wrapperCol="BaseTool.Constant.wrapperCol2"
  395. >
  396. <a-select v-decorator="['content']" placeholder="请选择">
  397. <a-select-option
  398. v-for="(label,value) in questionMap"
  399. :key="value"
  400. :label="label"
  401. :value="parseInt(value)">{{ label }}
  402. </a-select-option>
  403. </a-select>
  404. </a-form-item>
  405. </row-item>-->
  406. <row-item>
  407. <a-form-item
  408. label="委托内容描述"
  409. :labelCol="BaseTool.Constant.labelCol2"
  410. :wrapperCol="BaseTool.Constant.wrapperCol2"
  411. >
  412. <a-textarea
  413. :rows="4"
  414. v-decorator="['content', {rules: [{required: true, message: '委托内容描述不能为空'}]}]"/>
  415. </a-form-item>
  416. </row-item>
  417. </row-list>
  418. </a-form>
  419. <template slot="footer">
  420. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  421. </template>
  422. <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  423. <part-info-select-modal ref="partInfoSelectModal" @selected="handlePartSelected"/>
  424. </a-modal>
  425. </template>
  426. <script>
  427. import pick from 'lodash.pick'
  428. import BaseTool from '../../../../utils/tool'
  429. import { addRepairApplicationForm, updateRepairApplicationForm, getSbPositions, getDispatchUser } from '@/api/repair/application-form'
  430. import PartInfoSelectModal from '@/views/part/info/modules/PartInfoSelectModal'
  431. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  432. import { queryUser } from '@/api/upms/user'
  433. import { uploadUrl } from '@/api/upms/file'
  434. import Vue from 'vue'
  435. import { ACCESS_TOKEN } from '@/store/mutation-types'
  436. import { fetchErrorTypeTree } from '@/api/repair/errortype'
  437. import { TreeSelect } from 'ant-design-vue'
  438. const SHOW_PARENT = TreeSelect.SHOW_PARENT
  439. export default {
  440. name: 'BaseRepairApplicationForm',
  441. data () {
  442. return {
  443. SHOW_PARENT,
  444. confirmLoading: false,
  445. modalTitle: null,
  446. professorMap: {},
  447. repairTypeMap: {},
  448. sbPositionList: [],
  449. form: this.$form.createForm(this),
  450. visible: false,
  451. sbId: null,
  452. // 下拉框map
  453. sourceMap: {},
  454. levelMap: {},
  455. questionMap: {},
  456. dispatchUserList: {},
  457. treeData: [],
  458. needStop: null,
  459. needStopMap: {},
  460. category: 0,
  461. categoryMap: {},
  462. trustMap: {},
  463. statusMap: {},
  464. userInfo: this.$store.getters.userInfo,
  465. userList: [],
  466. uploadUrl: uploadUrl,
  467. defaultRepairFileList: [],
  468. defaultApplicationFileList: [],
  469. defaultCheckFileList: [],
  470. applicationFileList: [], // 报修图片
  471. reportFileList: [], // 审核图片
  472. repairFileList: [], // 维修图片,
  473. repairDeptMap: {},
  474. refusedFlag: false,
  475. headers: {
  476. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  477. }
  478. }
  479. },
  480. components: {
  481. SbInfoSelectModal,
  482. PartInfoSelectModal
  483. },
  484. props: {
  485. },
  486. created () {
  487. // 下拉框map
  488. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  489. // this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  490. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  491. this.questionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_QUESTION)
  492. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  493. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LEVEL_TYPE)
  494. this.categoryMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  495. this.trustMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.TRUST_DEPT_TYPE)
  496. console.log(this.categoryMap)
  497. this.repairDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_DEPT_CATEGORY)
  498. this.repairTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_TYPE)
  499. this.professorMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_PROFESSOR)
  500. this.getUsers()
  501. this.getSbPositions()
  502. },
  503. methods: {
  504. base (record) {
  505. this.visible = true
  506. this.refusedFlag = false
  507. fetchErrorTypeTree().then(res => {
  508. this.treeData = res.data
  509. })
  510. // 如果是空标识添加
  511. if (this.BaseTool.Object.isBlank(record)) {
  512. this.modalTitle = '报修'
  513. if (!this.BaseTool.Object.isBlank(record) && !this.BaseTool.Object.isBlank(record.sbId)) {
  514. const { form: { setFieldsValue } } = this
  515. this.$nextTick(() => {
  516. setFieldsValue(Object.assign(pick(record, [
  517. 'sbId',
  518. 'sbName'
  519. ])))
  520. })
  521. }
  522. return
  523. }
  524. if (this.BaseTool.Object.isBlank(record.id)) {
  525. this.modalTitle = '报修'
  526. if (!this.BaseTool.Object.isBlank(record.sbId)) {
  527. const { form: { setFieldsValue } } = this
  528. this.$nextTick(() => {
  529. setFieldsValue(Object.assign(pick(record, [
  530. 'sbId',
  531. 'sbName',
  532. 'sbCph'
  533. ])))
  534. })
  535. }
  536. return
  537. }
  538. this.modalTitle = '编辑'
  539. this.applicationFileList = record.applicationFileList
  540. this.repairFileList = record.repairFileList
  541. this.reportFileList = record.reportFileList
  542. this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(this.applicationFileList)
  543. this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
  544. this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(this.reportFileList)
  545. if (record.status === this.DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REFUSED_REPAIR) {
  546. this.refusedFlag = true
  547. }
  548. const { form: { setFieldsValue } } = this
  549. // 日期处理
  550. record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  551. if (record.limitDate != null) {
  552. record.limitDate = this.BaseTool.Moment(record.limitDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  553. this.$nextTick(() => {
  554. setFieldsValue(Object.assign(pick(record, [
  555. 'limitDate'
  556. ])))
  557. })
  558. }
  559. this.$nextTick(() => {
  560. setFieldsValue(Object.assign(pick(record, [
  561. 'id',
  562. 'sbId',
  563. 'sbCph',
  564. 'partId',
  565. 'repairUserId',
  566. 'no',
  567. 'category',
  568. 'limitDate',
  569. 'limitHours',
  570. 'source',
  571. 'level',
  572. 'content',
  573. 'status',
  574. 'sbName',
  575. 'needStop',
  576. 'category',
  577. 'partName',
  578. 'remark',
  579. 'repairDeptId'
  580. ])))
  581. })
  582. },
  583. getSbPositions (parentId) {
  584. getSbPositions({ parentId }).then(res => {
  585. console.log(res)
  586. this.sbPositionList = res.data.map(item => {
  587. item = {
  588. label: item.name,
  589. value: item.name,
  590. id: item.id,
  591. isLeaf: false
  592. }
  593. return item
  594. })
  595. })
  596. },
  597. loadData (selectedOptions) {
  598. console.log(selectedOptions)
  599. const targetOption = selectedOptions[selectedOptions.length - 1]
  600. targetOption.loading = true
  601. getSbPositions({ parentId: targetOption.id }).then(res => {
  602. targetOption.loading = false
  603. targetOption.children = res.data.map(item => {
  604. item = {
  605. label: item.name,
  606. value: item.name
  607. }
  608. return item
  609. })
  610. this.sbPositionList = [...this.sbPositionList]
  611. })
  612. },
  613. getUsers () {
  614. queryUser({ status: 1 }).then(res => {
  615. this.userList = res.data
  616. })
  617. getDispatchUser().then(res => {
  618. console.log(res)
  619. this.dispatchUserList = res.data
  620. })
  621. },
  622. save () {
  623. const { form: { validateFieldsAndScroll } } = this
  624. this.confirmLoading = true
  625. validateFieldsAndScroll((errors, values) => {
  626. if (errors) {
  627. this.confirmLoading = false
  628. return
  629. }
  630. // 日期处理
  631. values.applyTime = this.BaseTool.Date.formatter(values.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  632. values.limitDate = BaseTool.Date.formatter(values.limitDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  633. values.planStartTime = BaseTool.Date.formatter(values.planStartTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  634. values.planEndTime = BaseTool.Date.formatter(values.planEndTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  635. // 上传文件
  636. values.repairFileList = this.repairFileList
  637. values.repairProfessor = values.repairProfessor.join(',')
  638. values.repairType = values.repairType.join(',')
  639. values.applicationFileList = this.applicationFileList
  640. values.reportFileList = this.reportFileList
  641. values.sbPosition = values.sbPosition.join('->')
  642. console.log(values)
  643. if (values.partId === undefined) {
  644. values.partId = ''
  645. }
  646. if (this.BaseTool.String.isBlank(values.id)) {
  647. addRepairApplicationForm(values)
  648. .then(() => {
  649. this.$notification.success({
  650. message: '报修成功!',
  651. duration: 3
  652. })
  653. this.handleCancel(values)
  654. }).catch(() => {
  655. this.confirmLoading = false
  656. })
  657. } else {
  658. updateRepairApplicationForm(values)
  659. .then(() => {
  660. this.handleCancel(values)
  661. }).catch(() => {
  662. this.confirmLoading = false
  663. })
  664. }
  665. })
  666. },
  667. changePlanFlag (value) {
  668. this.category = value
  669. const { form: { setFieldsValue } } = this
  670. if (this.category === 1) {
  671. this.$nextTick(() => {
  672. setFieldsValue({ needStop: 1 })
  673. })
  674. } else {
  675. this.$nextTick(() => {
  676. setFieldsValue({ needStop: 0 })
  677. })
  678. }
  679. },
  680. handleCancel (values) {
  681. this.visible = false
  682. this.confirmLoading = false
  683. this.applicationFileList = []
  684. this.defaultApplicationFileList = []
  685. this.form.resetFields()
  686. if (this.BaseTool.Object.isNotBlank(values)) {
  687. this.$emit('ok', values)
  688. }
  689. },
  690. handleSbSelect () {
  691. this.$refs.sbInfoSelectModal.base({}, {})
  692. },
  693. handleSbSelectd (keys, rows) {
  694. const [ key ] = keys
  695. const [ row ] = rows
  696. const { form: { setFieldsValue } } = this
  697. this.sbId = key
  698. // 日期处理
  699. this.$nextTick(() => {
  700. setFieldsValue(Object.assign({
  701. 'sbId': key,
  702. 'sbName': row.name,
  703. 'sbCph': row.cph,
  704. 'parentSbNo': row.ppNo
  705. }))
  706. })
  707. },
  708. handlePartSelect () {
  709. if (this.sbId === null) {
  710. return this.$message.error('选择设备部位之前,请选择设备')
  711. }
  712. this.$refs.partInfoSelectModal.base({ sbId: this.sbId })
  713. },
  714. handlePartSelected (keys, rows) {
  715. const [ key ] = keys
  716. const [ row ] = rows
  717. const { form: { setFieldsValue } } = this
  718. this.$nextTick(() => {
  719. setFieldsValue(Object.assign({
  720. 'partId': key,
  721. 'partName': row.name
  722. }))
  723. })
  724. },
  725. handleCheckFileChange (info) {
  726. this.defaultCheckFileList = info.fileList
  727. this.reportFileList = this.setFileList(info, 32)
  728. },
  729. handleApplicationFileChange (info) {
  730. this.defaultApplicationFileList = info.fileList
  731. this.applicationFileList = this.setFileList(info, 11)
  732. },
  733. setFileList (info, type) {
  734. const file = info.file
  735. const fileList = info.fileList
  736. if (file.status === 'done') {
  737. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  738. } else if (file.status === 'removed') {
  739. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  740. } else if (file.status === 'error') {
  741. this.$message.error('上传失败')
  742. return []
  743. }
  744. }
  745. }
  746. }
  747. </script>