DetailSbCheckJob.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. </div>
  44. <a-table
  45. :data-source="data"
  46. :columns="columns"
  47. tableLayout="auto"
  48. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  49. :scroll="{x: 1500 }"
  50. rowKey="id">
  51. <span slot="action" slot-scope="record">
  52. <template>
  53. <a v-if="$auth('sb-infos-edit')" @click="handleView(record)">查看</a>
  54. <a-divider type="vertical" />
  55. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  56. <a-divider type="vertical" />
  57. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  58. <a>删除</a>
  59. </a-popconfirm>
  60. <a-divider type="vertical" />
  61. <a @click="handleGenerate(record)">插入任务</a>
  62. </template>
  63. </span>
  64. <span slot="status" slot-scope="text">
  65. <badge
  66. :status="DictCache.COLOR.JOB_STATUS[text]"
  67. :text="statusMap[text]" />
  68. </span>
  69. </a-table>
  70. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  71. <detail ref="detailModal" @ok="handleOk"/>
  72. </div>
  73. </template>
  74. <script>
  75. import DetailList from '@/components/tools/DetailList'
  76. import { queryCheckJob, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJobBatch, finishJobBatch } from '@/api/check/checkjob'
  77. import BaseForm from './BaseForm'
  78. import Detail from './Detail'
  79. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  80. const DetailListItem = DetailList.Item
  81. export default {
  82. name: 'DetailSbCheck',
  83. components: {
  84. DetailList,
  85. DetailListItem,
  86. BaseForm,
  87. Detail,
  88. SbInfoSelectModal
  89. },
  90. props: {
  91. /**
  92. * 检查类型: 1-点检 2-巡检
  93. */
  94. checkType: {
  95. type: Number,
  96. default: 2
  97. }
  98. },
  99. data () {
  100. return {
  101. status: null,
  102. selectedRowKeys: [], // Check here to configure the default column
  103. optionAlertShow: false,
  104. confirmLoading: false,
  105. mdl: {},
  106. model: {
  107. 'id': null,
  108. 'modelId': null,
  109. 'no': null,
  110. 'zbh': null,
  111. 'name': null,
  112. 'nameModel': null,
  113. 'unit': null,
  114. 'level': null,
  115. 'useType': null
  116. },
  117. modalTitle: null,
  118. visible: false,
  119. typeMap: {},
  120. standardLevelMap: {},
  121. statusMap: {},
  122. actionTypeMap: {},
  123. // 表头
  124. columns: [
  125. {
  126. title: '序号',
  127. dataIndex: 'index',
  128. checked: true,
  129. width: '100px',
  130. customRender: (text, record, index) => {
  131. return index + 1
  132. }
  133. },
  134. {
  135. title: '任务要求',
  136. dataIndex: 'requirement',
  137. checked: true,
  138. width: '300px'
  139. },
  140. {
  141. title: '负责人',
  142. dataIndex: 'checkUserName',
  143. checked: true,
  144. width: '100px'
  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: 'status',
  192. checked: true,
  193. width: '100px',
  194. fixed: 'right',
  195. scopedSlots: { customRender: 'status' }
  196. },
  197. {
  198. title: '操作',
  199. key: 'action',
  200. width: '250px',
  201. align: 'center',
  202. fixed: 'right',
  203. scopedSlots: { customRender: 'action' },
  204. checked: true
  205. }
  206. ],
  207. data: []
  208. }
  209. },
  210. created () {
  211. // 下拉框map
  212. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  213. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  214. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  215. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  216. this.standardLevelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  217. },
  218. methods: {
  219. base (record) {
  220. this.visible = true
  221. this.model = record
  222. this.modalTitle = '详情2'
  223. queryCheckJob({ sbId: record.id, type: this.checkType }).then(res => {
  224. this.data = res.data
  225. })
  226. },
  227. handleOk () {
  228. queryCheckJob({ sbId: this.model.id, type: this.checkType }).then(res => {
  229. this.data = res.data
  230. })
  231. },
  232. handleAdd () {
  233. const modal = this.$refs.baseModal
  234. modal.base(null, this.model.id)
  235. },
  236. handleView (record) {
  237. fetchCheckJob({ id: record.id }).then(res => {
  238. const modal = this.$refs.detailModal
  239. res.data.partName = record.partName
  240. modal.base(res.data)
  241. })
  242. },
  243. handleEdit (record) {
  244. fetchCheckJob({ id: record.id }).then(res => {
  245. const modal = this.$refs.baseModal
  246. modal.base(res.data)
  247. })
  248. },
  249. handleGenerate (record) {
  250. const modal = this.$refs.baseModalInsert
  251. modal.base(null, record.id)
  252. },
  253. handleCancel () {
  254. this.visible = false
  255. this.selectedRowKeys = []
  256. this.confirmLoading = false
  257. this.$emit('ok')
  258. },
  259. batchDelete (id) {
  260. let ids = []
  261. if (this.BaseTool.String.isBlank(id)) {
  262. if (length === 0) {
  263. this.$message.info('请选择要删除的记录')
  264. return
  265. }
  266. ids = this.selectedRows.map(item => item.id)
  267. } else {
  268. ids = [id]
  269. }
  270. deleteCheckJobs(ids).then(res => {
  271. this.$message.info('删除成功')
  272. this.handleOk()
  273. })
  274. },
  275. doExport () {
  276. const parameter = {
  277. ...this.queryParam
  278. }
  279. parameter.modelId = this.model.id
  280. exportCheckJob(parameter).then(file => {
  281. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  282. })
  283. },
  284. handleSbSelect () {
  285. this.$refs.sbInfoSelectModal.base()
  286. },
  287. onSelectChange (selectedRowKeys) {
  288. this.selectedRowKeys = selectedRowKeys
  289. },
  290. handleExecuteBatch () {
  291. let ids = []
  292. const length = this.selectedRowKeys.length
  293. if (length === 0) {
  294. this.$message.info('请选择记录')
  295. return
  296. }
  297. console.log(this.selectedRowKeys)
  298. ids = this.selectedRowKeys
  299. executeJobBatch(ids).then(res => {
  300. this.$message.info('接收成功')
  301. this.handleOk()
  302. })
  303. },
  304. handleFinishBatch () {
  305. let ids = []
  306. const length = this.selectedRowKeys.length
  307. if (length === 0) {
  308. this.$message.info('请选择记录')
  309. return
  310. }
  311. ids = this.selectedRowKeys
  312. finishJobBatch(ids).then(res => {
  313. this.$message.info('完成成功')
  314. this.handleOk()
  315. })
  316. },
  317. statusChange (value) {
  318. queryCheckJob({ sbId: this.model.id, type: this.checkType, status: value }).then(res => {
  319. this.data = res.data
  320. })
  321. }
  322. }
  323. }
  324. </script>