DebugForm.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right">
  6. <a-button type="primary" @click="save()">提交</a-button>
  7. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  8. </span>
  9. </a-col>
  10. </a-row>
  11. <title-divider title="基本信息" width="90px"></title-divider>
  12. <a-form :form="form">
  13. <a-form-item v-show="false" >
  14. <a-input v-decorator="['id']" type="hidden"/>
  15. <a-input v-decorator="['parentId']" type="hidden"/>
  16. </a-form-item>
  17. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  18. <a-col :lg="12" :md="24" :sm="24">
  19. <a-form-item
  20. label="设备(新号)"
  21. :labelCol="BaseTool.Constant.labelCol"
  22. :wrapperCol="BaseTool.Constant.wrapperCol"
  23. >
  24. <a-input
  25. v-decorator="['no', {rules: [{required: true, message: '不能为空'}]}]" />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :lg="12" :md="24" :sm="24">
  29. <a-form-item
  30. label="设备(旧号)"
  31. :labelCol="BaseTool.Constant.labelCol"
  32. :wrapperCol="BaseTool.Constant.wrapperCol"
  33. >
  34. <a-input
  35. v-decorator="['zbh', {rules: [{required: false, message: '不能为空'}]}]" />
  36. </a-form-item>
  37. </a-col>
  38. </a-row>
  39. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  40. <a-col :lg="12" :md="24" :sm="24">
  41. <a-form-item
  42. label="设备名称"
  43. :labelCol="BaseTool.Constant.labelCol"
  44. :wrapperCol="BaseTool.Constant.wrapperCol"
  45. >
  46. <a-input
  47. v-decorator="['name', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  48. </a-form-item>
  49. </a-col>
  50. <a-col :lg="12" :md="24" :sm="24">
  51. <a-form-item
  52. label="型号"
  53. :labelCol="BaseTool.Constant.labelCol"
  54. :wrapperCol="BaseTool.Constant.wrapperCol"
  55. >
  56. <a-input
  57. v-decorator="['model', {rules: [{required: true, message: '设备型号不能为空'}]}]" />
  58. </a-form-item>
  59. </a-col>
  60. </a-row>
  61. <title-divider title="安装调试意见" width="120px"></title-divider>
  62. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  63. <a-col :lg="12" :md="24" :sm="24">
  64. <a-form-item
  65. label="安装意见"
  66. :labelCol="BaseTool.Constant.labelCol"
  67. :wrapperCol="BaseTool.Constant.wrapperCol"
  68. >
  69. <a-textarea
  70. :rows="4"
  71. v-decorator="['fdjh']"/>
  72. </a-form-item>
  73. </a-col>
  74. <a-col :lg="12" :md="24" :sm="24">
  75. <a-form-item
  76. label="调试意见"
  77. :labelCol="BaseTool.Constant.labelCol"
  78. :wrapperCol="BaseTool.Constant.wrapperCol"
  79. >
  80. <a-textarea
  81. :rows="4"
  82. v-decorator="['zz']"/>
  83. </a-form-item>
  84. </a-col>
  85. </a-row>
  86. <title-divider title="安装调试文件" width="120px"></title-divider>
  87. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  88. <a-col :lg="12" :md="24" :sm="24">
  89. <a-form-item
  90. label="安装调试单"
  91. :labelCol="BaseTool.Constant.labelCol"
  92. :wrapperCol="BaseTool.Constant.wrapperCol"
  93. >
  94. <a-upload
  95. :action="uploadUrl"
  96. :multiple="true"
  97. :file-list="this.defaultRepairFileList"
  98. @change="handleRepairFileChange"
  99. :headers="headers"
  100. >
  101. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  102. </a-upload>
  103. </a-form-item>
  104. </a-col>
  105. <a-col :lg="12" :md="24" :sm="24">
  106. <a-form-item
  107. label="调试照片"
  108. :labelCol="BaseTool.Constant.labelCol"
  109. :wrapperCol="BaseTool.Constant.wrapperCol"
  110. >
  111. <a-upload
  112. :action="uploadUrl"
  113. :multiple="true"
  114. :file-list="this.defaultSbFileList"
  115. @change="handleSbFileChange"
  116. accept="image/*"
  117. :headers="headers"
  118. >
  119. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  120. </a-upload>
  121. </a-form-item>
  122. </a-col>
  123. </a-row>
  124. </a-form>
  125. </a-card>
  126. </template>
  127. <script>
  128. import pick from 'lodash.pick'
  129. import { addSbInfo, updateSbInfo, fetchSbInfo, copySbInfo } from '@/api/sb/info'
  130. import BaseTool from '../../../../utils/tool'
  131. import { ACCESS_TOKEN } from '@/store/mutation-types'
  132. import Vue from 'vue'
  133. import { uploadUrl } from '@/api/upms/file'
  134. import DetailList from '@/components/tools/DetailList'
  135. const DetailListItem = DetailList.Item
  136. export default {
  137. name: 'BaseSbInfo',
  138. components: {
  139. DetailList,
  140. DetailListItem
  141. },
  142. data () {
  143. return {
  144. confirmLoading: false,
  145. modalTitle: null,
  146. form: this.$form.createForm(this),
  147. areaList: {},
  148. companyList: {},
  149. paramList: [],
  150. projectList: {},
  151. deptList: {},
  152. groupList: {},
  153. visible: false,
  154. sbTypeTreeData: [],
  155. // sbInfoTreeData: [],
  156. // sourceSbInfoTreeData: [],
  157. // sbPositionTreeData: [],
  158. depreciationTypeMap: {},
  159. sourceTypeMap: {},
  160. levelMap: {},
  161. rlTypeMap: {},
  162. colorMap: {},
  163. useTypeMap: {},
  164. statusMap: {},
  165. isChildMap: {},
  166. isShowMap: {},
  167. isFinancingMap: {},
  168. userList: {},
  169. unitMap: {},
  170. sbInfoSelectType: null,
  171. repairFileList: [], // 维修手册
  172. defaultRepairFileList: [],
  173. defaultUseFileList: [],
  174. defaultRecheckFileList: [],
  175. defaultSbFileList: [],
  176. useFileList: [], // 使用手册
  177. recheckFileList: [], // 验收手册
  178. sbFileList: [], // 设备图片,
  179. uploadUrl: uploadUrl,
  180. qrcodesrc: null,
  181. id: null,
  182. fileList: [],
  183. type: null,
  184. headers: {
  185. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  186. }
  187. }
  188. },
  189. props: {
  190. useType: {
  191. type: Number,
  192. default: 3
  193. }
  194. },
  195. created () {
  196. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  197. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  198. this.colorMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_COLOR)
  199. this.rlTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.RANLIAO_TYPE)
  200. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  201. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  202. },
  203. methods: {
  204. base (record, type) {
  205. // 清除文件列表
  206. this.visible = true
  207. // 选择框查询条件
  208. // 如果是空标识添加
  209. if (this.BaseTool.Object.isBlank(record)) {
  210. this.qrcodesrc = null
  211. this.modalTitle = '添加'
  212. this.clearFileList()
  213. return
  214. }
  215. this.useType = record.useType
  216. this.modalTitle = '编辑'
  217. this.id = record.id
  218. this.qrcodesrc = record.qrCode
  219. this.repairFileList = record.repairFileList
  220. this.useFileList = record.useFileList
  221. this.recheckFileList = record.recheckFileList
  222. this.sbFileList = record.sbFileList
  223. this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
  224. this.defaultUseFileList = this.BaseTool.UPLOAD.transImg(this.useFileList)
  225. this.defaultRecheckFileList = this.BaseTool.UPLOAD.transImg(this.recheckFileList)
  226. this.defaultSbFileList = this.BaseTool.UPLOAD.transImg(this.sbFileList)
  227. this.paramList = JSON.parse(record.paramList)
  228. if (type === 1) {
  229. this.type = type
  230. this.modalTitle = '复制'
  231. this.qrcodesrc = null
  232. record.no = null
  233. this.clearFileList()
  234. }
  235. const { form: { setFieldsValue } } = this
  236. // 日期处理
  237. // record.buyDate = this.BaseTool.Moment(record.buyDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  238. // record.startDate = this.BaseTool.Moment(record.startDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  239. // record.nextCheckDate = this.BaseTool.Moment(record.nextCheckDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  240. // record.guaranteeDate = this.BaseTool.Moment(record.guaranteeDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  241. // record.retirementDate = this.BaseTool.Moment(record.retirementDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  242. // record.lastRepaireTime = this.BaseTool.Moment(record.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  243. // record.lastBaoyangTime = this.BaseTool.Moment(record.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  244. if (record.buyDate != null) {
  245. record.buyDate = this.BaseTool.Moment(record.buyDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  246. this.$nextTick(() => {
  247. setFieldsValue(Object.assign(pick(record, [
  248. 'buyDate'
  249. ])))
  250. })
  251. }
  252. if (record.startDate != null) {
  253. record.startDate = this.BaseTool.Moment(record.startDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  254. this.$nextTick(() => {
  255. setFieldsValue(Object.assign(pick(record, [
  256. 'startDate'
  257. ])))
  258. })
  259. }
  260. if (record.checkDate != null) {
  261. record.checkDate = this.BaseTool.Moment(record.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  262. this.$nextTick(() => {
  263. setFieldsValue(Object.assign(pick(record, [
  264. 'checkDate'
  265. ])))
  266. })
  267. }
  268. if (record.nextCheckDate != null) {
  269. record.nextCheckDate = this.BaseTool.Moment(record.nextCheckDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  270. this.$nextTick(() => {
  271. setFieldsValue(Object.assign(pick(record, [
  272. 'nextCheckDate'
  273. ])))
  274. })
  275. }
  276. if (record.retirementDate != null) {
  277. record.retirementDate = this.BaseTool.Moment(record.retirementDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  278. this.$nextTick(() => {
  279. setFieldsValue(Object.assign(pick(record, [
  280. 'retirementDate'
  281. ])))
  282. })
  283. }
  284. if (record.registerDate != null) {
  285. record.registerDate = this.BaseTool.Moment(record.registerDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  286. this.$nextTick(() => {
  287. setFieldsValue(Object.assign(pick(record, [
  288. 'registerDate'
  289. ])))
  290. })
  291. }
  292. record.unitName = this.BaseTool.Object.getField(this.unitMap, record.unit)
  293. record.useTypeName = this.BaseTool.Object.getField(this.useTypeMap, record.useType)
  294. this.$nextTick(() => {
  295. setFieldsValue(Object.assign(pick(record, [
  296. 'id',
  297. 'no',
  298. 'parentId',
  299. 'parentSbName',
  300. 'isChild',
  301. 'isShow',
  302. 'isFinancing',
  303. 'financingNo',
  304. 'financingNoTwo',
  305. 'financingNoThird',
  306. 'financingNoFour',
  307. 'financingNoFive',
  308. 'name',
  309. 'model',
  310. 'cph',
  311. 'positionId',
  312. 'producerName',
  313. 'useArea',
  314. 'useCompany',
  315. 'useProject',
  316. 'useDept',
  317. 'saveUser',
  318. 'repairUser',
  319. 'useGroup',
  320. 'typeId',
  321. 'level',
  322. 'initialValue',
  323. // 'cutValue',
  324. 'producerId',
  325. // 'sourceType',
  326. 'unit',
  327. 'buyDate',
  328. 'startDate',
  329. 'zbh',
  330. // 'wbFile',
  331. // 'useFile',
  332. // 'checkFile',
  333. // 'sbImage',
  334. 'status',
  335. 'remark',
  336. 'zzh',
  337. 'zz',
  338. 'zjm',
  339. 'jbdh',
  340. 'useType',
  341. 'cardNo',
  342. 'fdjxh',
  343. 'checkDate',
  344. 'checkPeriod',
  345. 'nextCheckDate',
  346. 'dph',
  347. 'zaiz',
  348. 'rlType',
  349. 'color',
  350. 'sbdh',
  351. 'seatNumber',
  352. 'registerNo',
  353. 'characterType',
  354. 'usedNo',
  355. 'supplier',
  356. 'repairUserSecond',
  357. 'batchNo',
  358. 'workYear',
  359. 'retirementDate',
  360. 'registerDate'
  361. ])))
  362. })
  363. },
  364. save () {
  365. const { form: { validateFieldsAndScroll } } = this
  366. this.confirmLoading = true
  367. validateFieldsAndScroll((errors, values) => {
  368. if (errors) {
  369. this.confirmLoading = false
  370. return
  371. }
  372. // 日期数据的处理
  373. values.buyDate = BaseTool.Date.formatter(values.buyDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  374. values.startDate = BaseTool.Date.formatter(values.startDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  375. values.checkDate = BaseTool.Date.formatter(values.checkDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  376. values.nextCheckDate = BaseTool.Date.formatter(values.nextCheckDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  377. values.guaranteeDate = BaseTool.Date.formatter(values.guaranteeDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  378. values.retirementDate = BaseTool.Date.formatter(values.retirementDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  379. values.lastRepaireTime = this.BaseTool.Date.formatter(values.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  380. values.lastBaoyangTime = this.BaseTool.Date.formatter(values.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  381. values.spDate = this.BaseTool.Date.formatter(values.spDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  382. values.jbdDate = this.BaseTool.Date.formatter(values.jbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  383. values.sbdDate = this.BaseTool.Date.formatter(values.sbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  384. values.sbDate = this.BaseTool.Date.formatter(values.sbDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  385. // 上传文件
  386. values.repairFileList = this.repairFileList
  387. values.useFileList = this.useFileList
  388. values.recheckFileList = this.recheckFileList
  389. values.sbFileList = this.sbFileList
  390. values.paramList = JSON.stringify(this.paramList)
  391. values.useType = this.useType
  392. if (this.BaseTool.String.isBlank(values.id)) {
  393. addSbInfo(values)
  394. .then(() => {
  395. this.handleCancel(values)
  396. }).catch(() => {
  397. this.confirmLoading = false
  398. })
  399. } else {
  400. if (this.type == null) {
  401. updateSbInfo(values)
  402. .then(() => {
  403. this.handleCancel(values)
  404. }).catch(() => {
  405. this.confirmLoading = false
  406. })
  407. } else {
  408. copySbInfo(values)
  409. .then(() => {
  410. this.handleCancel(values)
  411. }).catch(() => {
  412. this.confirmLoading = false
  413. })
  414. }
  415. }
  416. })
  417. },
  418. getQrcodeSrc () {
  419. console.log(111, 22)
  420. },
  421. handleCancel () {
  422. this.visible = false
  423. this.confirmLoading = false
  424. this.form.resetFields()
  425. this.$emit('ok')
  426. },
  427. handleFresh () {
  428. fetchSbInfo({ id: this.id }).then(res => {
  429. const { form: { setFieldsValue } } = this
  430. const record = res.data
  431. this.$nextTick(() => {
  432. setFieldsValue(Object.assign(pick(record, [
  433. 'zjm',
  434. 'jbdh'
  435. ])))
  436. })
  437. })
  438. },
  439. beforeRecheckFileListUpload (file) {
  440. const reg = /\.(xls|xlsx)(\?.*)?$/
  441. return new Promise((resolve, reject) => {
  442. if (reg.test(file.name)) {
  443. this.recheckFileList = [file]
  444. return true
  445. } else {
  446. this.$message.error(`请上传正确的xls|xlsx文件`)
  447. reject(new Error('请上传正确的xls|xlsx文件'))
  448. return false
  449. }
  450. })
  451. },
  452. beforeUploadPic (file) {
  453. const reg = /\.(jpg|jpeg|png)(\?.*)?$/
  454. return new Promise((resolve, reject) => {
  455. if (reg.test(file.name)) {
  456. this.sbFileList = [file]
  457. return true
  458. } else {
  459. this.$message.error(`请上传正确的jpg|jpeg|png文件`)
  460. reject(new Error('请上传正确的jpg|jpeg|png文件'))
  461. return false
  462. }
  463. })
  464. },
  465. clearFileList () {
  466. this.repairFileList = []
  467. this.useFileList = []
  468. this.recheckFileList = []
  469. this.sbFileList = []
  470. },
  471. handleRepairFileChange (info) {
  472. this.defaultRepairFileList = info.fileList
  473. this.repairFileList = this.setFileList(info, 1)
  474. },
  475. handleUseFileChange (info) {
  476. this.defaultUseFileList = info.fileList
  477. this.useFileList = this.setFileList(info, 2)
  478. },
  479. handleRecheckFileChange (info) {
  480. this.defaultRecheckFileList = info.fileList
  481. this.recheckFileList = this.setFileList(info, 3)
  482. },
  483. handleSbFileChange (info) {
  484. this.defaultSbFileList = info.fileList
  485. this.sbFileList = this.setFileList(info, 4)
  486. },
  487. setFileList1 (info, type) {
  488. const fileList = [...info.fileList]
  489. const file = [...info.file]
  490. if (file.status === 'done') {
  491. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  492. } else if (file.status === 'removed') {
  493. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  494. } else if (file.status === 'error') {
  495. this.$message.error('上传失败')
  496. return []
  497. }
  498. },
  499. clearParent () {
  500. const { form: { setFieldsValue } } = this
  501. // 日期处理
  502. this.$nextTick(() => {
  503. setFieldsValue(Object.assign({
  504. 'parentId': null,
  505. 'parentSbName': null
  506. }))
  507. })
  508. },
  509. setFileList (info, type) {
  510. // { file, fileList }
  511. const file = info.file
  512. const fileList = info.fileList
  513. // fileList = fileList.slice(-2)
  514. // console.log(111, this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type))
  515. if (file.status === 'done') {
  516. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  517. } else if (file.status === 'removed') {
  518. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  519. } else if (file.status === 'error') {
  520. this.$message.error('上传失败')
  521. return null
  522. }
  523. }
  524. }
  525. }
  526. </script>