DetailSbCheckJob.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div v-show="visible">
  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 style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  7. </span>
  8. </a-col>
  9. </a-row>
  10. <title-divider title="设备信息" width="90px"></title-divider>
  11. <detail-list title="" :col="3">
  12. <detail-list-item term="设备新号">{{ model.no }}</detail-list-item>
  13. <detail-list-item term="设备旧号">{{ model.zbh }}</detail-list-item>
  14. <detail-list-item term="型号">{{ model.model }}</detail-list-item>
  15. <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
  16. </detail-list>
  17. <title-divider title="保养任务" width="90px"></title-divider>
  18. <div class="table-operator" style="margin-bottom:8px;">
  19. <!-- <a-button type="primary" @click="handleAdd">
  20. <a-icon type="plus"/>
  21. 添加
  22. </a-button>-->
  23. <a-button type="primary" @click="handleExecuteBatch" v-if="selectedRowKeys.length > 0">
  24. <a-icon style="margin-left: 8px" type="plus" />
  25. 批量接收
  26. </a-button>
  27. <a-button style="margin-left: 8px" type="primary" v-if="selectedRowKeys.length > 0" @click="handleFinishBatch">
  28. <a-icon type="plus" />
  29. 批量完成
  30. </a-button>
  31. <a-button style="margin-left: 8px" type="primary" icon="download" @click="doExport">导出</a-button>
  32. <a-select style="margin-left: 8px;width:100px;" @change="statusChange" placeholder="请选择">
  33. <a-select-option v-for="(label,value) in statusMap" :key="value" :label="label" :value="parseInt(value)">{{ label }}
  34. </a-select-option>
  35. </a-select>
  36. <a-select style="margin-left: 8px;width:100px;" @change="levelChange" placeholder="请选择">
  37. <a-select-option v-for="(label,value) in standardLevelMap" :key="value" :label="label" :value="parseInt(value)">{{ label }}
  38. </a-select-option>
  39. </a-select>
  40. </div>
  41. <a-table :data-source="data" :columns="columns" tableLayout="auto" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :scroll="{x: 1500, y: BaseTool.Constant.scrollY }" rowKey="id">
  42. <span slot="action" slot-scope="record">
  43. <template>
  44. <a v-if="$auth('sb-infos-edit')" @click="handleView(record)">查看</a>
  45. <a-divider type="vertical" />
  46. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  47. <a-divider type="vertical" />
  48. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  49. <a>删除</a>
  50. </a-popconfirm>
  51. <a-divider type="vertical" />
  52. <a @click="handleGenerate(record)">插入任务</a>
  53. </template>
  54. </span>
  55. <span slot="status" slot-scope="text">
  56. <badge :status="DictCache.COLOR.JOB_STATUS[text]" :text="statusMap[text]" />
  57. </span>
  58. </a-table>
  59. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk" />
  60. <detail ref="detailModal" @ok="handleOk" />
  61. </div>
  62. </template>
  63. <script>
  64. import DetailList from '@/components/tools/DetailList'
  65. import {
  66. queryCheckJob,
  67. deleteCheckJobs,
  68. fetchCheckJob,
  69. exportCheckJob,
  70. executeJobBatch,
  71. finishJobBatch,
  72. } from '@/api/check/checkjob'
  73. import BaseForm from './BaseForm'
  74. import Detail from './Detail'
  75. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  76. const DetailListItem = DetailList.Item
  77. export default {
  78. name: 'DetailSbCheck',
  79. components: {
  80. DetailList,
  81. DetailListItem,
  82. BaseForm,
  83. Detail,
  84. SbInfoSelectModal,
  85. },
  86. props: {
  87. /**
  88. * 检查类型: 1-点检 2-巡检
  89. */
  90. checkType: {
  91. type: Number,
  92. default: 2,
  93. },
  94. },
  95. data() {
  96. return {
  97. status: null,
  98. selectedRowKeys: [], // Check here to configure the default column
  99. optionAlertShow: false,
  100. confirmLoading: false,
  101. mdl: {},
  102. model: {
  103. id: null,
  104. modelId: null,
  105. no: null,
  106. zbh: null,
  107. name: null,
  108. nameModel: null,
  109. unit: null,
  110. level: null,
  111. useType: null,
  112. },
  113. modalTitle: null,
  114. visible: false,
  115. typeMap: {},
  116. standardLevelMap: {},
  117. statusMap: {},
  118. actionTypeMap: {},
  119. // 表头
  120. columns: [
  121. {
  122. title: '序号',
  123. dataIndex: 'index',
  124. checked: true,
  125. width: '100px',
  126. customRender: (text, record, index) => {
  127. return index + 1
  128. },
  129. },
  130. {
  131. title: '标准编码',
  132. dataIndex: 'standardNo',
  133. checked: true,
  134. width: '150px',
  135. },
  136. {
  137. title: '任务要求',
  138. dataIndex: 'requirement',
  139. checked: true,
  140. width: '300px',
  141. },
  142. {
  143. title: '负责人',
  144. dataIndex: 'checkUserName',
  145. checked: true,
  146. width: '100px',
  147. customRender: (text, record) => {
  148. return record.actualUser || text || '-'
  149. },
  150. },
  151. {
  152. title: '设备',
  153. dataIndex: 'sbName',
  154. checked: true,
  155. width: '100px',
  156. },
  157. {
  158. title: '部位',
  159. dataIndex: 'partName',
  160. checked: true,
  161. width: '100px',
  162. },
  163. {
  164. title: '维护等级',
  165. dataIndex: 'standardLevel',
  166. width: '100px',
  167. checked: true,
  168. customRender: (text, record, index) => {
  169. return this.BaseTool.Table.getMapText(this.standardLevelMap, text)
  170. },
  171. },
  172. {
  173. title: '执行日期',
  174. dataIndex: 'startTime',
  175. checked: true,
  176. width: '200px',
  177. },
  178. // 截至日期由系统按执行周期自动推算,保养标准中无对应录入项,暂不展示
  179. /* {
  180. title: '截至日期',
  181. dataIndex: 'endTime',
  182. checked: true,
  183. width: '200px',
  184. }, */
  185. {
  186. title: '开始时间',
  187. dataIndex: 'actualStartTime',
  188. width: '200px',
  189. },
  190. {
  191. title: '完成时间',
  192. dataIndex: 'actualEndTime',
  193. width: '200px',
  194. },
  195. {
  196. title: '是否延期',
  197. dataIndex: 'receiveOvertime',
  198. checked: true,
  199. fixed: 'right',
  200. width: '100px',
  201. customRender: (text, record, index) => {
  202. return text === null || text === 0 ? '否' : '是'
  203. },
  204. },
  205. {
  206. title: '任务状态',
  207. dataIndex: 'status',
  208. checked: true,
  209. width: '100px',
  210. fixed: 'right',
  211. scopedSlots: { customRender: 'status' },
  212. },
  213. {
  214. title: '操作',
  215. key: 'action',
  216. width: '250px',
  217. align: 'center',
  218. fixed: 'right',
  219. scopedSlots: { customRender: 'action' },
  220. checked: true,
  221. },
  222. ],
  223. data: [],
  224. }
  225. },
  226. created() {
  227. // 下拉框map
  228. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  229. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  230. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  231. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  232. this.standardLevelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  233. },
  234. methods: {
  235. base(record) {
  236. this.visible = true
  237. this.model = record
  238. this.modalTitle = '详情2'
  239. queryCheckJob({
  240. sbId: record.id,
  241. type: this.checkType,
  242. statusList: [
  243. this.DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE,
  244. this.DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING,
  245. ].join(','),
  246. }).then((res) => {
  247. this.data = res.data
  248. })
  249. },
  250. handleOk() {
  251. queryCheckJob({
  252. sbId: this.model.id,
  253. type: this.checkType,
  254. statusList: [
  255. this.DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE,
  256. this.DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING,
  257. ].join(','),
  258. }).then((res) => {
  259. this.data = res.data
  260. })
  261. },
  262. handleAdd() {
  263. const modal = this.$refs.baseModal
  264. modal.base(null, this.model.id)
  265. },
  266. handleView(record) {
  267. fetchCheckJob({ id: record.id }).then((res) => {
  268. const modal = this.$refs.detailModal
  269. res.data.partName = record.partName
  270. modal.base(res.data)
  271. })
  272. },
  273. handleEdit(record) {
  274. fetchCheckJob({ id: record.id }).then((res) => {
  275. const modal = this.$refs.baseModal
  276. modal.base(res.data)
  277. })
  278. },
  279. handleGenerate(record) {
  280. const modal = this.$refs.baseModalInsert
  281. modal.base(null, record.id)
  282. },
  283. handleCancel() {
  284. this.visible = false
  285. this.selectedRowKeys = []
  286. this.confirmLoading = false
  287. this.$emit('ok')
  288. },
  289. batchDelete(id) {
  290. let ids = []
  291. if (this.BaseTool.String.isBlank(id)) {
  292. if (length === 0) {
  293. this.$message.info('请选择要删除的记录')
  294. return
  295. }
  296. ids = this.selectedRows.map((item) => item.id)
  297. } else {
  298. ids = [id]
  299. }
  300. deleteCheckJobs(ids).then((res) => {
  301. this.$message.info('删除成功')
  302. this.handleOk()
  303. })
  304. },
  305. doExport() {
  306. const parameter = {
  307. ...this.queryParam,
  308. }
  309. parameter.modelId = this.model.id
  310. exportCheckJob(parameter).then((file) => {
  311. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  312. })
  313. },
  314. handleSbSelect() {
  315. this.$refs.sbInfoSelectModal.base()
  316. },
  317. onSelectChange(selectedRowKeys) {
  318. this.selectedRowKeys = selectedRowKeys
  319. },
  320. handleExecuteBatch() {
  321. let ids = []
  322. const length = this.selectedRowKeys.length
  323. if (length === 0) {
  324. this.$message.info('请选择记录')
  325. return
  326. }
  327. console.log(this.selectedRowKeys)
  328. ids = this.selectedRowKeys
  329. executeJobBatch(ids).then((res) => {
  330. this.$message.info('接收成功')
  331. this.handleOk()
  332. })
  333. },
  334. handleFinishBatch() {
  335. let ids = []
  336. const length = this.selectedRowKeys.length
  337. if (length === 0) {
  338. this.$message.info('请选择记录')
  339. return
  340. }
  341. ids = this.selectedRowKeys
  342. finishJobBatch(ids).then((res) => {
  343. this.$message.info('完成成功')
  344. this.handleOk()
  345. })
  346. },
  347. statusChange(value) {
  348. queryCheckJob({ sbId: this.model.id, type: this.checkType, status: value }).then((res) => {
  349. this.data = res.data
  350. })
  351. },
  352. levelChange(value) {
  353. queryCheckJob({ sbId: this.model.id, type: this.checkType, level: value }).then((res) => {
  354. this.data = res.data
  355. })
  356. },
  357. },
  358. }
  359. </script>