BaseForm.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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="uploadVisible = true">上传图片 </a-button>
  115. <a-modal v-model="uploadVisible" title="上传图片" @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. ],
  194. applicationFileList: [],
  195. headers: {
  196. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  197. },
  198. confirmLoading: false,
  199. visible: false,
  200. uploadVisible: false,
  201. previewVisible: false,
  202. previewImage: '',
  203. model: {},
  204. listPage: {
  205. pageNum: 1,
  206. pageSize: 10,
  207. total: 0
  208. },
  209. pagination: {
  210. pageNum: 1,
  211. pageSize: 10,
  212. total: 0
  213. },
  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. return item
  301. })
  302. })
  303. console.log(this.ListForm)
  304. },
  305. handleRepair (val) {
  306. const data = {
  307. sbId: val.sbId,
  308. sbName: val.sbName,
  309. sbCph: val.positionName,
  310. applicationFileList: this.applicationFileList,
  311. defaultApplicationFileList: this.defaultApplicationFileList,
  312. treeData: val.content.map((item) => {
  313. return {
  314. title: item.name + ':' + item.fillValue,
  315. value: item.name + ':' + item.fillValue,
  316. key: item.name + ':' + item.fillValue
  317. }
  318. })
  319. }
  320. console.log(data)
  321. const modal = this.$refs.baseFormRepairModal
  322. modal.base(data)
  323. },
  324. getBase64 (file) {
  325. return new Promise((resolve, reject) => {
  326. const reader = new FileReader()
  327. reader.readAsDataURL(file)
  328. reader.onload = () => resolve(reader.result)
  329. reader.onerror = error => reject(error)
  330. })
  331. },
  332. async handlePreview (file) {
  333. if (!file.url && !file.preview) {
  334. file.preview = await this.getBase64(file.originFileObj)
  335. }
  336. this.previewImage = file.url || file.preview
  337. this.previewVisible = true
  338. },
  339. handleApplicationFileChange (info) {
  340. this.defaultApplicationFileList = info.fileList
  341. this.applicationFileList = this.setFileList(info, 11)
  342. },
  343. setFileList (info, type) {
  344. const file = info.file
  345. const fileList = info.fileList
  346. if (file.status === 'done') {
  347. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  348. } else if (file.status === 'removed') {
  349. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  350. } else if (file.status === 'error') {
  351. this.$message.error('上传失败')
  352. return []
  353. }
  354. },
  355. handleDispatch (record) {
  356. this.visible = false
  357. const modal = this.$refs.dispatchModal
  358. modal.base(record)
  359. },
  360. handleVerify (record) {
  361. const modal = this.$refs.verifyModal
  362. modal.base(record)
  363. },
  364. handleOvertime (record) {
  365. this.visible = false
  366. const modal = this.$refs.overtimeModal
  367. modal.base(record)
  368. },
  369. handlePause (record) {
  370. this.visible = false
  371. const modal = this.$refs.pauseModal
  372. modal.base(record)
  373. },
  374. getFillUpdates () {
  375. const params = {
  376. ...this.pagination,
  377. taskId: this.id
  378. }
  379. getFillUpdates(params).then(res => {
  380. this.updatesInfo = res.data.rows
  381. this.pagination.total = res.data.total
  382. })
  383. },
  384. handleStatusChange (e) {
  385. this.status = e.target.value
  386. this.getInfo()
  387. },
  388. handleTableChange (pagination) {
  389. console.log(pagination)
  390. const pager = { ...this.pagination }
  391. pager.pageNum = pagination.current
  392. this.pagination = pager
  393. this.getFillUpdates()
  394. },
  395. onChange (page) {
  396. console.log(page)
  397. this.getInfo()
  398. },
  399. save () {
  400. const detail = this.ListForm.map(item => {
  401. return {
  402. id: item.id,
  403. content: JSON.stringify(item.content)
  404. }
  405. })
  406. const params = {
  407. id: this.id,
  408. details: detail,
  409. applicationFileList: this.applicationFileList
  410. }
  411. fillGatherTask(params).then(res => {
  412. console.log(res)
  413. this.handleCancel()
  414. })
  415. },
  416. handleConfirm (id) {
  417. console.log(id)
  418. },
  419. handleOk () {
  420. this.visible = true
  421. },
  422. handleCancel () {
  423. this.visible = false
  424. this.ListForm = []
  425. this.type = 1
  426. this.status = null
  427. this.$emit('ok')
  428. }
  429. }
  430. }
  431. </script>
  432. <style lang="less" scoped>
  433. // table,table tr th, table tr td { border:1px solid #666; }
  434. // table { min-height: 25px; line-height: 25px; text-align: center; border-collapse: collapse;}
  435. // td {
  436. // padding: 5px 10px;
  437. // }
  438. .tables{
  439. margin: 20px 0px;
  440. width: 100%;
  441. overflow-x:auto;
  442. table {
  443. min-width:100%;
  444. margin: 0 auto;
  445. border: 1px solid #D6D6D6;
  446. border-collapse: collapse;
  447. font-size: 16px;
  448. font-weight: 400;
  449. table-layout:fixed;
  450. }
  451. th{
  452. background: #fafafa;
  453. font-weight: 500;
  454. }
  455. th,
  456. td {
  457. border: 1px solid #D6D6D6;
  458. text-align: center;
  459. padding: 5px 10px;
  460. white-space: nowrap;
  461. }
  462. }
  463. </style>