BaseForm.vue 15 KB

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