CheckStandard.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="编码/名称">
  9. <a-input v-model="queryParam.keyword" placeholder="编码/名称" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="设备新号">
  14. <a-input v-model="queryParam.sbNo" placeholder="请输入设备新号" />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="设备名称">
  19. <a-input v-model="queryParam.sbName" placeholder="请输入设备名称" />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="设备类型">
  24. <a-tree-select style="width: 100%" :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  25. :treeData="treeData" :treeNodeFilterProp="'title'" :showSearch="true" v-model="queryParam.typeIdList"
  26. multiple allowClear placeholder="请选择">
  27. </a-tree-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="设备等级">
  32. <a-select mode="multiple" v-model="queryParam.sbLevelList" placeholder="请选择">
  33. <a-select-option v-for="(label, value) in sbLevelMap" :key="value" :label="label"
  34. :value="parseInt(value)">{{ label }}
  35. </a-select-option>
  36. </a-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="维护等级">
  41. <a-select mode="multiple" v-model="queryParam.levelList" placeholder="请选择">
  42. <a-select-option v-for="(label, value) in levelMap" :key="value" :label="label"
  43. :value="parseInt(value)">{{ label }}
  44. </a-select-option>
  45. </a-select>
  46. </a-form-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24">
  49. <a-form-item label="计划周期">
  50. <a-select mode="multiple" v-model="queryParam.periodTypeList" placeholder="请选择">
  51. <a-select-option v-for="(label, value) in periodTypeMap" :key="value" :label="label"
  52. :value="parseInt(value)">{{ label }}
  53. </a-select-option>
  54. </a-select>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24" v-if="checkType === 2">
  58. <a-form-item label="执行人/班组">
  59. <a-input v-model="queryParam.checkUserName" placeholder="请输入执行人/班组" />
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6 || 24" :sm="24">
  63. <span class="table-page-search-submitButtons">
  64. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  65. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  66. </span>
  67. </a-col>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <a-space class="table-operator">
  72. <a-button v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))" type="primary"
  73. icon="plus" @click="$refs.baseModal.base()">新增
  74. </a-button>
  75. <a-button v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))" type="primary"
  76. icon="plus" @click="handleBatchAdd">批量新增
  77. </a-button>
  78. <a-button v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))" type="primary"
  79. icon="upload" @click="handleBatchImport">批量导入
  80. </a-button>
  81. <a-button v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))"
  82. icon="download" @click="handleDownloadTemplate">下载导入模板
  83. </a-button>
  84. <!-- 隐藏批量调整标准按钮 -->
  85. <!--
  86. <a-button v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))"
  87. :disabled="selectedRowKeys.length === 0" type="primary" icon="plus" @click="handleBatchEdit">批量调整标准
  88. </a-button>
  89. -->
  90. <!-- <a-button style="margin-left:8px;" type="primary" @click="doImport">
  91. <a-icon type="upload"/>
  92. 新增导入
  93. </a-button> -->
  94. <!-- 导入/导出功能暂时隐藏:v-if="false" 控制,后续启用改回原判断即可 -->
  95. <a-button v-if="false" type="primary" @click="doImportOldVersion">
  96. <a-icon type="upload" />
  97. 导入
  98. </a-button>
  99. <!-- <a-button style="margin-left:8px;" type="primary" @click="doImportByUpdate">
  100. <a-icon type="upload"/>
  101. 修改导入
  102. </a-button> -->
  103. <a-button v-if="false" type="primary" icon="download" @click="doExport">导出
  104. </a-button>
  105. <a-button :confirmLoading="confirmLoading" type="primary" @click="doUpdateNo">
  106. <a-icon type="upload" />
  107. 初始化编码
  108. </a-button>
  109. <a-dropdown v-action:edit
  110. v-if="selectedRowKeys.length > 0 && ($auth('check-spot-standards-del') || $auth('check-polling-standards-del'))">
  111. <a-menu slot="overlay">
  112. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  113. <a-menu-item key="1">
  114. <a-icon type="delete" />
  115. <a>删除</a></a-menu-item>
  116. </a-popconfirm>
  117. </a-menu>
  118. <a-button>
  119. 批量操作
  120. <a-icon type="down" />
  121. </a-button>
  122. </a-dropdown>
  123. </a-space>
  124. <s-table ref="table" size="default" rowKey="id" :columns="columns"
  125. :scroll="{ x: checkType === 2 ? 1650 : 1500, y: BaseTool.Constant.scrollY }" :data="loadData" :alert="options.alert"
  126. :rowSelection="options.rowSelection" showPagination="auto">
  127. <span slot="enable" slot-scope="text">
  128. <badge :status="DictCache.COLOR.YES_NO[text]" :text="enableMap[text]" />
  129. </span>
  130. <span slot="action" slot-scope="record">
  131. <template>
  132. <a @click="handleView(record)">查看</a>
  133. <a-divider type="vertical" />
  134. <a @click="handleViewCheckJob(record)">保养任务</a>
  135. <a-divider type="vertical" />
  136. <a v-if="($auth('check-spot-standards-edit') || $auth('check-polling-standards-edit'))"
  137. @click="handleEdit(record)">修改</a>
  138. <a-divider type="vertical" />
  139. <a-popconfirm v-if="($auth('check-spot-standards-del') || $auth('check-polling-standards-del'))"
  140. title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  141. <a>删除</a>
  142. </a-popconfirm>
  143. <a-divider type="vertical" />
  144. <a @click="handleCopy(record)">复制</a>
  145. </template>
  146. </span>
  147. </s-table>
  148. </div>
  149. <detail-standard-check-job ref="detailSbCheckJobModal" @ok="handleOk" />
  150. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk" />
  151. <BatchBaseForm ref="batchBaseForm" :check-type="checkType" @ok="handleOk" />
  152. <BatchImportStandard ref="batchImportModal" @ok="handleOk" />
  153. <detail ref="detailModal" :check-type="checkType" />
  154. <import-form-update ref="importModal" @ok="handleOk" />
  155. <BatchEditForm ref="batchEditForm" @ok="handleOk" />
  156. </a-card>
  157. </template>
  158. <script>
  159. import { STable, Ellipsis } from '@/components'
  160. import BaseForm from './modules/BaseForm'
  161. import BatchBaseForm from './modules/BatchBaseForm'
  162. import BatchImportStandard from './modules/BatchImportStandard'
  163. import Detail from './modules/Detail'
  164. import BatchEditForm from './modules/BatchEditForm'
  165. import ImportFormUpdate from './modules/ImportFormUpdate'
  166. import {
  167. getCheckStandardPage,
  168. deleteCheckStandards,
  169. updateCheckStandardNo,
  170. fetchCheckStandard,
  171. exportCheckStandard,
  172. downloadCheckStandardImportTemplate,
  173. } from '@/api/check/checkstandard'
  174. import DetailStandardCheckJob from '@/views/check/checkjob/modules/DetailStandardCheckJob.vue'
  175. import { fetchSbTypeTree } from '@/api/sb/type'
  176. export default {
  177. name: 'CheckStandardList',
  178. components: {
  179. STable,
  180. Ellipsis,
  181. BaseForm,
  182. Detail,
  183. ImportFormUpdate,
  184. DetailStandardCheckJob,
  185. BatchBaseForm,
  186. BatchEditForm,
  187. BatchImportStandard,
  188. },
  189. props: {
  190. /**
  191. * 检查类型: 1-点检 2-巡检
  192. */
  193. checkType: {
  194. type: Number,
  195. default: 1,
  196. },
  197. },
  198. data() {
  199. return {
  200. // 查询参数
  201. visible: true,
  202. confirmLoading: false,
  203. queryParam: {},
  204. // 表头
  205. columns: [
  206. {
  207. title: '序号',
  208. dataIndex: 'index',
  209. width: '100px',
  210. checked: true,
  211. customRender: (text, record, index) => {
  212. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1
  213. }`
  214. },
  215. },
  216. {
  217. title: '设备新号',
  218. dataIndex: 'sbNo',
  219. checked: true,
  220. width: '100px',
  221. },
  222. {
  223. title: '设备名称',
  224. dataIndex: 'sbName',
  225. checked: true,
  226. width: '150px',
  227. },
  228. ...(this.checkType === 2
  229. ? [
  230. {
  231. title: '创建人',
  232. dataIndex: 'createdUserName',
  233. checked: true,
  234. width: '120px',
  235. customRender: (text) => text || '-',
  236. },
  237. ]
  238. : []),
  239. ,
  240. /* {
  241. title: '标准编码',
  242. dataIndex: 'no',
  243. checked: true,
  244. width: '150px',
  245. }
  246. {
  247. title: '部位',
  248. dataIndex: 'partName',
  249. checked: true,
  250. width: '200px'
  251. }, */ {
  252. title: '维护等级',
  253. dataIndex: 'level',
  254. width: '100px',
  255. checked: true,
  256. customRender: (text, record, index) => {
  257. return this.BaseTool.Table.getMapText(this.levelMap, text)
  258. },
  259. },
  260. this.checkType === 2
  261. ? {
  262. title: '执行人/班组',
  263. dataIndex: 'checkDeptName',
  264. checked: true,
  265. width: '200px',
  266. customRender: (text, record, index) => {
  267. return record.checkDeptName || record.checkUserName || '-'
  268. },
  269. }
  270. : {
  271. title: '检查标准',
  272. dataIndex: 'remark',
  273. checked: true,
  274. width: '250px',
  275. customRender: (text, record, index) => {
  276. if (text != null) {
  277. if (text.length > 40) {
  278. return text.slice(0, 40)
  279. } else {
  280. return text
  281. }
  282. } else {
  283. return text
  284. }
  285. },
  286. },
  287. {
  288. title: '计划周期',
  289. dataIndex: 'period',
  290. width: '100px',
  291. checked: true,
  292. customRender: (text, record, index) => {
  293. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  294. },
  295. },
  296. {
  297. title: '预计下次执行日期',
  298. dataIndex: 'nextDate',
  299. checked: true,
  300. width: '200px',
  301. },
  302. {
  303. title: '上次执行日期',
  304. dataIndex: 'lastDate',
  305. fixed: 'right',
  306. checked: true,
  307. width: '200px',
  308. },
  309. {
  310. title: '操作',
  311. key: 'action',
  312. width: '300px',
  313. checked: true,
  314. fixed: 'right',
  315. align: 'center',
  316. scopedSlots: { customRender: 'action' },
  317. },
  318. ],
  319. // 下拉框map
  320. actionTypeMap: {},
  321. typeMap: {},
  322. enableMap: {},
  323. periodTypeMap: {},
  324. levelMap: {},
  325. sbLevelMap: {},
  326. treeData: [],
  327. checkUserTypeMap: {},
  328. // 加载数据方法 必须为 Promise 对象
  329. loadData: (parameter) => {
  330. parameter = {
  331. ...parameter,
  332. ...this.queryParam,
  333. dataScope: {},
  334. type: this.checkType,
  335. }
  336. return getCheckStandardPage(Object.assign(parameter, this.queryParam)).then((res) => {
  337. return res.data
  338. })
  339. },
  340. selectedRowKeys: [],
  341. selectedRows: [],
  342. options: {
  343. alert: {
  344. show: true,
  345. clear: () => {
  346. this.selectedRowKeys = []
  347. },
  348. },
  349. rowSelection: {
  350. selectedRowKeys: this.selectedRowKeys,
  351. onChange: this.onSelectChange,
  352. },
  353. },
  354. optionAlertShow: false,
  355. }
  356. },
  357. created() {
  358. // 下拉框map
  359. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  360. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  361. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  362. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  363. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  364. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  365. this.sbLevelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  366. fetchSbTypeTree().then((res) => {
  367. this.treeData = res.data
  368. })
  369. this.tableOption()
  370. },
  371. methods: {
  372. tableOption() {
  373. if (!this.optionAlertShow) {
  374. this.options = {
  375. alert: {
  376. show: true,
  377. clear: () => {
  378. this.selectedRowKeys = []
  379. },
  380. },
  381. rowSelection: {
  382. selectedRowKeys: this.selectedRowKeys,
  383. onChange: this.onSelectChange,
  384. getCheckboxProps: (record) => ({
  385. props: {
  386. disabled: false,
  387. name: record.id,
  388. },
  389. }),
  390. },
  391. }
  392. this.optionAlertShow = true
  393. } else {
  394. this.options = {
  395. alert: false,
  396. rowSelection: null,
  397. }
  398. this.optionAlertShow = false
  399. }
  400. },
  401. batchDelete(id) {
  402. let ids = []
  403. if (this.BaseTool.String.isBlank(id)) {
  404. const length = this.selectedRows.length
  405. if (length === 0) {
  406. this.$message.info('请选择要删除的记录')
  407. return
  408. }
  409. ids = this.selectedRows.map((item) => item.id)
  410. } else {
  411. ids = [id]
  412. }
  413. deleteCheckStandards(ids).then((res) => {
  414. this.$message.info('删除成功')
  415. this.handleOk()
  416. this.$refs.table.clearSelected()
  417. })
  418. },
  419. doUpdateNo(record) {
  420. this.confirmLoading = true
  421. updateCheckStandardNo().then((res) => {
  422. this.confirmLoading = false
  423. this.$message.info('编码生成成功')
  424. this.handleOk()
  425. this.$refs.table.clearSelected()
  426. })
  427. },
  428. handleEdit(record) {
  429. fetchCheckStandard({ id: record.id }).then((res) => {
  430. const modal = this.$refs.baseModal
  431. res.data.sbNo = record.sbNo
  432. modal.base(res.data)
  433. })
  434. },
  435. handleView(record) {
  436. fetchCheckStandard({ id: record.id }).then((res) => {
  437. const modal = this.$refs.detailModal
  438. modal.base(res.data, record)
  439. })
  440. },
  441. handleViewCheckJob(record) {
  442. this.visible = false
  443. const modal = this.$refs.detailSbCheckJobModal
  444. modal.base(record)
  445. },
  446. handleBatchAdd() {
  447. this.visible = false
  448. const modal = this.$refs.batchBaseForm
  449. modal.base()
  450. },
  451. handleBatchImport() {
  452. this.$refs.batchImportModal.base()
  453. },
  454. handleDownloadTemplate() {
  455. downloadCheckStandardImportTemplate().then((file) => {
  456. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  457. })
  458. },
  459. handleCopy(record) {
  460. fetchCheckStandard({ id: record.id }).then((res) => {
  461. const modal = this.$refs.baseModal
  462. res.data.id = null
  463. modal.base(res.data)
  464. })
  465. },
  466. handleOk() {
  467. this.visible = true
  468. this.$refs.table.refresh()
  469. },
  470. onSelectChange(selectedRowKeys, selectedRows) {
  471. this.selectedRowKeys = selectedRowKeys
  472. this.selectedRows = selectedRows
  473. },
  474. resetSearchForm() {
  475. this.queryParam = {}
  476. this.$refs.table.refresh(true)
  477. },
  478. doImport() {
  479. this.$refs.importModal.base(0)
  480. },
  481. doImportOldVersion() {
  482. this.$refs.importModal.base(1)
  483. },
  484. doImportByUpdate() {
  485. this.$refs.importModal.base(2)
  486. },
  487. handleBatchEdit() {
  488. this.$refs.batchEditForm.base(this.selectedRowKeys)
  489. },
  490. doExport() {
  491. const parameter = {
  492. ...this.queryParam,
  493. }
  494. exportCheckStandard(parameter).then((file) => {
  495. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  496. })
  497. },
  498. },
  499. }
  500. </script>