DetailStandardCheckJob.vue 10 KB

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