DetailSbCheckJob.vue 11 KB

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