BaseForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card">
  3. <a-row :gutter="48" style="position:fixed;bottom:150px; left:50%;z-index:999;display:flex; justify-content: center">
  4. <a-col :md="48" :sm="48">
  5. <span>
  6. <a-button v-show="editor" :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  7. <a-button style="margin-left: 8px" :loading="confirmLoading" type="primary" @click="handleAdd()">新增</a-button>
  8. <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
  9. <a-button
  10. style="margin-left: 8px"
  11. type="primary"
  12. v-show="!editor&&model.status == 2 "
  13. @click="handleVerify(model)"
  14. > 审核</a-button>
  15. <a-button
  16. v-if="$auth('fill-tasks-dispatch')"
  17. v-show="!editor&&model.status!== 6&&model.status!== 2"
  18. style="margin-left: 8px"
  19. type="primary"
  20. @click="handleDispatch(model)"
  21. >转派</a-button>
  22. <a-button
  23. v-if="$auth('fill-tasks-overtime')"
  24. v-show="!editor&&model.status!== 2&&model.status!== 6"
  25. style="margin-left: 8px"
  26. type="primary"
  27. @click="handleOvertime(model)"
  28. >延时</a-button>
  29. <a-button
  30. v-if="$auth('fill-tasks-pause')"
  31. v-show="!editor && model.status===5&&model.status!== 2&&model.status!== 6"
  32. style="margin-left: 8px"
  33. type="primary"
  34. @click="handlePause(model)"
  35. >取消暂停</a-button>
  36. <a-button
  37. v-if="$auth('fill-tasks-pause')"
  38. v-show="!editor&& model.status!==5&&model.status!== 2&&model.status!== 6"
  39. style="margin-left: 8px"
  40. type="primary"
  41. @click="handlePause(model)"
  42. >暂停</a-button>
  43. </span>
  44. </a-col>
  45. </a-row>
  46. <a-button-group size="large" v-show="!editor" >
  47. <a-button @click="type=1">
  48. <a-icon type="left" />巡检记录
  49. </a-button>
  50. <a-button @click="type=2">
  51. 任务追踪<a-icon type="right" />
  52. </a-button>
  53. </a-button-group>
  54. <div v-show="type===1">
  55. <div class="tables">
  56. <a-radio-group :value="status" @change="handleStatusChange">
  57. <a-radio-button :value="null">
  58. 全部
  59. </a-radio-button>
  60. <a-radio-button :value="0">
  61. 未填报
  62. </a-radio-button>
  63. <a-radio-button :value="1">
  64. 已填报
  65. </a-radio-button>
  66. </a-radio-group>
  67. <div style="text-align:center;padding-bottom:10px;font-size:32px;">数字工厂巡检记录表</div>
  68. <div v-show="!editor" style="display:flex; justify-content: space-between;">
  69. <div> 巡检开始时间:{{ model.createdTime }}</div>
  70. <div> 巡检要求时间:{{ model.requireHour }}小时</div>
  71. <div> 巡检预警时间:{{ model.warningHour }}小时</div>
  72. <div> 巡检完成时间:{{ model.updateTime }}</div>
  73. <div> 巡检人:{{ model.checkerName }}</div>
  74. </div>
  75. <table>
  76. <thead border="1px">
  77. <tr>
  78. <th rowspan="2" width="100px">序号</th>
  79. <th rowspan="2" width="150px">车间</th>
  80. <th rowspan="2" width="150px">设备名称</th>
  81. <th rowspan="2" width="150px">设备位号</th>
  82. <th rowspan="2" width="150px">设备编号</th>
  83. <th rowspan="2" width="150px">填报时间</th>
  84. <th :colspan="ListForm.length>0?ListForm[0].content.length:1">项目内容项</th>
  85. <th rowspan="2" width="150px">是否填报</th>
  86. <th rowspan="2" width="150px" >操作</th>
  87. </tr>
  88. <tr v-if="ListForm.length>0">
  89. <th v-for="item in ListForm[0].content" :key="item.name">{{ item.name }}</th>
  90. </tr>
  91. </thead>
  92. <tbody v-if="ListForm.length>0">
  93. <tr v-for="(item,i) in ListForm" :key="item.id">
  94. <td>{{ i+1 }}</td>
  95. <td>{{ item.positionName }}</td>
  96. <td>{{ item.sbName }}</td>
  97. <td>{{ item.positionNo }}</td>
  98. <td>{{ item.sbNo }}</td>
  99. <td>{{ item.updateTime }}</td>
  100. <td v-for="li in item.content" :key="li.name">
  101. <span v-if="!editor" > {{ li.fillValue }}</span>
  102. <a-input style="min-width:100px" v-else-if="li.type === 1 && editor " v-model="li.fillValue" />
  103. <a-select v-else-if="li.type === 2 && editor" v-model="li.fillValue" style="min-width:100px;">
  104. <a-select-option v-for="val in JSON.parse(li.selectValue)" :key="val.value" :value="val.value">
  105. {{ val.value }}
  106. </a-select-option>
  107. </a-select>
  108. <a-date-picker style="min-width:100px;" v-else-if="li.type === 3 && editor" show-time :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN" v-model="li.fillValue" />
  109. </td>
  110. <td>
  111. <a-icon v-show="item.status === 1" type="check" style="color:#87d068;font-size: 26px;" />
  112. </td>
  113. <td>
  114. <a-button v-if="editor" type="link" @click="handleRepair(item)">
  115. 报修
  116. </a-button>
  117. <a-button type="link" @click="uploadImg(item,i)">{{ item.images&&item.images.length?'查看图片':'上传图片' }}</a-button>
  118. <operation-button
  119. :type="2"
  120. title="是否要删除该条数据?"
  121. @confirm="handleDelete(item.id)">删除</operation-button>
  122. <a-modal v-model="uploadVisible" title="上传图片" :footer="null" @cancel="uploadVisible = false">
  123. <a-upload
  124. :disabled="!editor"
  125. :action="uploadUrl"
  126. list-type="picture-card"
  127. :file-list="defaultApplicationFileList"
  128. @change="handleApplicationFileChange"
  129. @preview="handlePreview"
  130. accept="image/*"
  131. :headers="headers"
  132. >
  133. <div>
  134. <a-icon type="plus" />
  135. <div class="ant-upload-text">
  136. Upload
  137. </div>
  138. </div>
  139. </a-upload>
  140. </a-modal>
  141. <a-modal :visible="previewVisible" :footer="null" @cancel="previewVisible = false" @ok="previewVisible = false">
  142. <img alt="example" style="width: 100%" :src="previewImage" />
  143. </a-modal>
  144. </td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. <div v-if="ListForm.length===0">
  149. <a-empty />
  150. </div>
  151. <a-pagination style="position:absolute;right:0; bottom:0px;" v-model="listPage.pageNum" :total="listPage.total" @change="onChange" />
  152. </div>
  153. </div>
  154. <div v-show="type===2">
  155. <div style="text-align:center;padding-bottom:10px;font-size:32px;">数字工厂仪表任务记录表</div>
  156. <a-table
  157. :columns="columns"
  158. :data-source="updatesInfo"
  159. bordered
  160. :pagination="pagination"
  161. @change="handleTableChange"
  162. :loading="loading">
  163. <template v-slot:index="text,record,index">
  164. {{ index+1 }}
  165. </template>
  166. <template v-slot:type="text">
  167. {{ typeMap[text] }}
  168. </template>
  169. </a-table>
  170. </div>
  171. <dispatch-form ref="dispatchModal" @ok="handleOk" />
  172. <overtime-form ref="overtimeModal" @ok="handleOk" />
  173. <pause-form ref="pauseModal" @ok="handleOk" />
  174. <verify-form ref="verifyModal" @ok="handleOk" />
  175. <base-form-repair ref="baseFormRepairModal" @ok="handleOk" />
  176. <sb-info-select-modal ref="sbInfoSelectModal" type="checkbox" @selected="handleSbSelectd"/>
  177. </a-card>
  178. </template>
  179. <script>
  180. import { fillGatherTask, getFillGatherTask, getFillUpdates, pauseFillGatherTask, updatetasks } from '@/api/fill/task'
  181. import DispatchForm from './DispatchForm'
  182. import OvertimeForm from './OvertimeForm'
  183. import BaseFormRepair from './BaseFormRepair'
  184. import SbInfoSelectModal from './SbInfoSelectModal.vue'
  185. import PauseForm from './PauseForm'
  186. import VerifyForm from './VerifyForm'
  187. import { uploadUrl } from '@/api/upms/file'
  188. import Vue from 'vue'
  189. import { ACCESS_TOKEN } from '@/store/mutation-types'
  190. export default {
  191. name: 'BaseFillGatherTask',
  192. components: {
  193. PauseForm,
  194. VerifyForm,
  195. DispatchForm,
  196. BaseFormRepair,
  197. SbInfoSelectModal,
  198. OvertimeForm
  199. },
  200. data () {
  201. return {
  202. uploadUrl: uploadUrl,
  203. defaultApplicationFileList: [],
  204. applicationFileList: [],
  205. headers: {
  206. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  207. },
  208. confirmLoading: false,
  209. visible: false,
  210. uploadVisible: false,
  211. previewVisible: false,
  212. previewImage: '',
  213. model: {},
  214. listPage: {
  215. pageNum: 1,
  216. pageSize: 10,
  217. total: 0
  218. },
  219. pagination: {
  220. pageNum: 1,
  221. pageSize: 10,
  222. total: 0
  223. },
  224. imgId: '',
  225. loading: false,
  226. ListForm: [],
  227. id: '',
  228. type: 1,
  229. typeMap: {},
  230. status: null,
  231. updatesInfo: [],
  232. ids: [],
  233. columns: [
  234. {
  235. title: '序号',
  236. width: 70,
  237. key: 'index',
  238. align: 'center',
  239. scopedSlots: { customRender: 'index' }
  240. },
  241. {
  242. title: '类型',
  243. width: 100,
  244. dataIndex: 'type',
  245. scopedSlots: { customRender: 'type' }
  246. },
  247. {
  248. title: '巡检人',
  249. width: 150,
  250. dataIndex: 'checkerName'
  251. },
  252. {
  253. title: '巡检主管',
  254. width: 150,
  255. dataIndex: 'leaderName'
  256. },
  257. {
  258. title: '记录时间',
  259. width: 150,
  260. dataIndex: 'createdTime'
  261. },
  262. {
  263. title: ' 延时时长',
  264. width: 150,
  265. dataIndex: 'lateHour'
  266. },
  267. {
  268. title: '备注',
  269. width: 150,
  270. dataIndex: 'remark'
  271. }
  272. ]
  273. // 下拉框map
  274. }
  275. },
  276. props: {
  277. editor: {
  278. type: Boolean,
  279. default: true
  280. }
  281. },
  282. created () {
  283. // 下拉框map
  284. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FILL_UPDATE_TYPE)
  285. },
  286. methods: {
  287. base (record) {
  288. this.visible = true
  289. this.model = record
  290. this.id = record.id
  291. this.getInfo()
  292. this.getFillUpdates()
  293. },
  294. getInfo () {
  295. const params = {
  296. ...this.listPage,
  297. taskId: this.id,
  298. status: this.status
  299. }
  300. getFillGatherTask(params).then(res => {
  301. if (res.data.rows.length === 0) {
  302. this.ListForm = []
  303. return
  304. }
  305. this.listPage.total = res.data.total
  306. this.ListForm = res.data.rows.map(item => {
  307. item.content = JSON.parse(item.content)
  308. item.content = item.content.map(val => {
  309. val.fillValue = val.fillValue ? val.fillValue : ''
  310. return val
  311. })
  312. item.images = item.content.filter(item => item.fileFormat)
  313. item.content = item.content.filter(item => !item.fileFormat)
  314. return item
  315. })
  316. console.log(this.ListForm)
  317. this.model.sbIds = this.ListForm.map(item => item.sbId)
  318. })
  319. },
  320. uploadImg (val, i) {
  321. this.uploadVisible = true
  322. console.log(val)
  323. this.imgId = i
  324. this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(val.images.map((item, i) => {
  325. item.id = i
  326. return item
  327. }))
  328. console.log(this.defaultApplicationFileList)
  329. console.log(this.applicationFileList)
  330. },
  331. handleRepair (val) {
  332. const data = {
  333. sbId: val.sbId,
  334. sbName: val.sbName,
  335. sbCph: val.positionName,
  336. applicationFileList: val.images,
  337. defaultApplicationFileList: this.BaseTool.UPLOAD.transImg(val.images),
  338. treeData: val.content.map((item) => {
  339. return {
  340. title: item.name + ':' + item.fillValue,
  341. value: item.name + ':' + item.fillValue,
  342. key: item.name + ':' + item.fillValue
  343. }
  344. })
  345. }
  346. const modal = this.$refs.baseFormRepairModal
  347. modal.base(data)
  348. },
  349. getBase64 (file) {
  350. return new Promise((resolve, reject) => {
  351. const reader = new FileReader()
  352. reader.readAsDataURL(file)
  353. reader.onload = () => resolve(reader.result)
  354. reader.onerror = error => reject(error)
  355. })
  356. },
  357. async handlePreview (file) {
  358. if (!file.url && !file.preview) {
  359. file.preview = await this.getBase64(file.originFileObj)
  360. }
  361. this.previewImage = file.url || file.preview
  362. this.previewVisible = true
  363. },
  364. handleApplicationFileChange (info) {
  365. this.defaultApplicationFileList = info.fileList
  366. this.applicationFileList = this.setFileList(info, 11)
  367. this.ListForm[this.imgId].images = this.applicationFileList
  368. },
  369. setFileList (info, type) {
  370. const file = info.file
  371. const fileList = info.fileList
  372. if (file.status === 'done') {
  373. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  374. } else if (file.status === 'removed') {
  375. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  376. } else if (file.status === 'error') {
  377. this.$message.error('上传失败')
  378. return []
  379. }
  380. },
  381. handleDispatch (record) {
  382. this.visible = false
  383. const modal = this.$refs.dispatchModal
  384. modal.base(record)
  385. },
  386. handleVerify (record) {
  387. const modal = this.$refs.verifyModal
  388. modal.base(record)
  389. },
  390. handleOvertime (record) {
  391. this.visible = false
  392. const modal = this.$refs.overtimeModal
  393. modal.base(record)
  394. },
  395. handlePause (record) {
  396. this.visible = false
  397. const modal = this.$refs.pauseModal
  398. modal.base(record)
  399. },
  400. getFillUpdates () {
  401. const params = {
  402. ...this.pagination,
  403. taskId: this.id
  404. }
  405. getFillUpdates(params).then(res => {
  406. this.updatesInfo = res.data.rows
  407. this.pagination.total = res.data.total
  408. })
  409. },
  410. handleStatusChange (e) {
  411. this.status = e.target.value
  412. this.getInfo()
  413. },
  414. handleTableChange (pagination) {
  415. console.log(pagination)
  416. const pager = { ...this.pagination }
  417. pager.pageNum = pagination.current
  418. this.pagination = pager
  419. this.getFillUpdates()
  420. },
  421. onChange (page) {
  422. this.getInfo()
  423. },
  424. save () {
  425. const detail = this.ListForm.map(item => {
  426. item.images.forEach((image) => {
  427. image.fillValue = 1
  428. })
  429. console.log(item.images)
  430. return {
  431. id: item.id,
  432. content: JSON.stringify([...item.content, ...item.images])
  433. }
  434. })
  435. const params = {
  436. id: this.id,
  437. details: detail,
  438. applicationFileList: this.applicationFileList,
  439. sbIds: this.model.sbIds
  440. }
  441. fillGatherTask(params).then(res => {
  442. console.log(res)
  443. this.handleCancel()
  444. })
  445. },
  446. handleConfirm (id) {
  447. console.log(id)
  448. },
  449. handleOk () {
  450. this.visible = true
  451. },
  452. handleCancel () {
  453. this.visible = false
  454. this.ListForm = []
  455. this.type = 1
  456. this.status = null
  457. this.$emit('ok')
  458. },
  459. handleDelete (id) {
  460. console.log(id)
  461. updatetasks({
  462. id: this.id,
  463. detailIds: [id],
  464. isAdd: 0
  465. }).then(res => {
  466. this.$message.info('操作成功!')
  467. this.getInfo()
  468. })
  469. },
  470. handleAdd () {
  471. this.ids = this.ListForm.map(item => item.sbId)
  472. this.$refs.sbInfoSelectModal.base({}, this.ids)
  473. },
  474. handleSbSelectd (keys, rows) {
  475. updatetasks({
  476. id: this.id,
  477. sbIds: keys,
  478. isAdd: 1
  479. }).then(res => {
  480. this.$message.info('操作成功!')
  481. this.getInfo()
  482. })
  483. }
  484. }
  485. }
  486. </script>
  487. <style lang="less" scoped>
  488. // table,table tr th, table tr td { border:1px solid #666; }
  489. // table { min-height: 25px; line-height: 25px; text-align: center; border-collapse: collapse;}
  490. // td {
  491. // padding: 5px 10px;
  492. // }
  493. .tables{
  494. margin: 20px 0px;
  495. width: 100%;
  496. overflow-x:auto;
  497. table {
  498. min-width:100%;
  499. margin: 0 auto;
  500. border: 1px solid #D6D6D6;
  501. border-collapse: collapse;
  502. font-size: 16px;
  503. font-weight: 400;
  504. table-layout:fixed;
  505. }
  506. th{
  507. background: #fafafa;
  508. font-weight: 500;
  509. }
  510. th,
  511. td {
  512. border: 1px solid #D6D6D6;
  513. text-align: center;
  514. padding: 5px 10px;
  515. white-space: nowrap;
  516. }
  517. }
  518. </style>