CheckStandard.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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.trim="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
  25. style="width: 100%"
  26. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  27. :treeData="treeData"
  28. :treeNodeFilterProp="'title'"
  29. :showSearch="true"
  30. v-model="queryParam.typeId"
  31. placeholder="请选择"
  32. >
  33. </a-tree-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="设备等级">
  38. <a-select v-model="queryParam.sbLevel" placeholder="请选择">
  39. <a-select-option
  40. v-for="(label,value) in sbLevelMap"
  41. :key="value"
  42. :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 v-model="queryParam.level" placeholder="请选择">
  51. <a-select-option
  52. v-for="(label,value) in levelMap"
  53. :key="value"
  54. :label="label"
  55. :value="parseInt(value)">{{ label }}
  56. </a-select-option>
  57. </a-select>
  58. </a-form-item>
  59. </a-col>
  60. <a-col :md="6" :sm="24">
  61. <a-form-item label="计划周期">
  62. <a-select v-model="queryParam.periodType" placeholder="请选择">
  63. <a-select-option
  64. v-for="(label,value) in periodTypeMap"
  65. :key="value"
  66. :label="label"
  67. :value="parseInt(value)">{{ label }}
  68. </a-select-option>
  69. </a-select>
  70. </a-form-item>
  71. </a-col>
  72. <a-col :md="6 || 24" :sm="24">
  73. <span class="table-page-search-submitButtons">
  74. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  75. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  76. </span>
  77. </a-col>
  78. </a-row>
  79. </a-form>
  80. </div>
  81. <div class="table-operator" style="margin-bottom: 8px;">
  82. <a-button
  83. v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))"
  84. type="primary"
  85. icon="plus"
  86. @click="$refs.baseModal.base(null,queryParam.sbId,queryParam.sbNo)">新增
  87. </a-button>
  88. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  89. <a-icon type="upload"/>
  90. 新增导入
  91. </a-button>
  92. <!-- <a-button style="margin-left:8px;" type="primary" @click="doImportOldVersion">
  93. <a-icon type="upload"/>
  94. 老版本导入
  95. </a-button>-->
  96. <a-button style="margin-left:8px;" type="primary" @click="doImportByUpdate">
  97. <a-icon type="upload"/>
  98. 修改导入
  99. </a-button>
  100. <a-button
  101. style="margin-left: 8px"
  102. v-if="($auth('check-spot-standards-export')||$auth('check-polling-standards-export'))"
  103. type="primary"
  104. icon="download"
  105. @click="doExport">导出
  106. </a-button>
  107. <a-button :confirmLoading="confirmLoading" style="margin-left:8px;" type="primary" @click="doUpdateNo">
  108. <a-icon type="upload"/>
  109. 初始化编码
  110. </a-button>
  111. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))">
  112. <a-menu slot="overlay">
  113. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  114. <a-menu-item key="1">
  115. <a-icon type="delete"/>
  116. <a>删除</a></a-menu-item>
  117. </a-popconfirm>
  118. </a-menu>
  119. <a-button style="margin-left: 8px">
  120. 批量操作
  121. <a-icon type="down"/>
  122. </a-button>
  123. </a-dropdown>
  124. </div>
  125. <s-table
  126. ref="table"
  127. size="default"
  128. rowKey="id"
  129. :columns="columns"
  130. :scroll="{x: 1500, y: BaseTool.Constant.scrollY }"
  131. :data="loadData"
  132. :alert="options.alert"
  133. :rowSelection="options.rowSelection"
  134. showPagination="auto"
  135. >
  136. <span slot="enable" slot-scope="text">
  137. <badge
  138. :status="DictCache.COLOR.YES_NO[text]"
  139. :text="enableMap[text]" />
  140. </span>
  141. <span slot="action" slot-scope="record">
  142. <template>
  143. <a @click="handleView(record)">查看</a>
  144. <a-divider type="vertical"/>
  145. <!-- <a @click="handleViewCheckJob(record)">保养任务</a>-->
  146. <a v-if="record.isGet==1 && checkType==2" @click="handleViewCheckJob(record)">保养任务</a>
  147. <a v-if="record.isGet==1 && checkType==1" @click="handleViewCheckJob(record)">点检任务</a>
  148. <a v-if="record.isGet==1 && checkType==3" @click="handleViewCheckJob(record)">润滑任务</a>
  149. <a v-if=" record.isGet==0 && checkType==2 " @click="addBYTask(record)">生成保养任务</a>
  150. <a v-if=" record.isGet==0 && checkType==1 " @click="addBYTask(record)">生成点检任务</a>
  151. <a v-if=" record.isGet==0 && checkType==3 " @click="addBYTask(record)">生成润滑任务</a>
  152. <a-divider type="vertical"/>
  153. <a v-if="($auth('check-spot-standards-edit')||$auth('check-polling-standards-edit'))" @click="handleEdit(record)">修改</a>
  154. <a-divider type="vertical"/>
  155. <a-popconfirm
  156. v-if="($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))"
  157. title="是否要删除该条数据?"
  158. @confirm="batchDelete(record.id)">
  159. <a>删除</a>
  160. </a-popconfirm>
  161. <a-divider type="vertical" />
  162. <a @click="handleCopy(record)">复制</a>
  163. </template>
  164. </span>
  165. </s-table>
  166. </div>
  167. <detail-standard-check-job ref="detailSbCheckJobModal" @ok="handleOk"/>
  168. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  169. <detail ref="detailModal"/>
  170. <import-form-add ref="importModal" @ok="handleOk"/>
  171. </a-card>
  172. </template>
  173. <script>
  174. import { STable, Ellipsis } from '@/components'
  175. import BaseForm from './modules/BaseForm'
  176. import Detail from './modules/Detail'
  177. import ImportFormAdd from './modules/ImportFormAdd'
  178. import {
  179. getCheckStandardPage,
  180. deleteCheckStandards,
  181. updateCheckStandardNo,
  182. fetchCheckStandard,
  183. exportCheckStandard,
  184. addBYTask
  185. } from '@/api/check/checkstandard'
  186. import DetailStandardCheckJob from '@/views/check/checkjob/modules/DetailStandardCheckJob'
  187. import { fetchSbTypeTree } from '@/api/sb/type'
  188. export default {
  189. name: 'CheckStandardList',
  190. components: {
  191. STable,
  192. Ellipsis,
  193. BaseForm,
  194. Detail,
  195. ImportFormAdd,
  196. DetailStandardCheckJob
  197. },
  198. props: {
  199. /**
  200. * 检查类型: 1-点检 2-保养 3-润滑
  201. */
  202. checkType: {
  203. type: Number,
  204. default: 1
  205. }
  206. },
  207. data () {
  208. return {
  209. // 查询参数
  210. visible: true,
  211. confirmLoading: false,
  212. queryParam: {
  213. type: this.$route.query.checkType || this.checkType,
  214. sbId: this.$route.query.id,
  215. sbNo: this.$route.query.sbNo
  216. },
  217. // 表头
  218. columns: [
  219. {
  220. title: '序号',
  221. dataIndex: 'index',
  222. width: '100px',
  223. checked: true,
  224. customRender: (text, record, index) => {
  225. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  226. }
  227. },
  228. {
  229. title: '设备编号',
  230. dataIndex: 'sbNo',
  231. checked: true,
  232. width: '100px'
  233. },
  234. {
  235. title: '设备名称',
  236. dataIndex: 'sbName',
  237. checked: true,
  238. width: '150px'
  239. },
  240. {
  241. title: '标准编码',
  242. dataIndex: 'no',
  243. checked: true,
  244. width: '150px'
  245. },
  246. {
  247. title: '类型',
  248. dataIndex: 'type',
  249. checked: true,
  250. width: '120px',
  251. customRender: (text, record, index) => {
  252. return this.BaseTool.Table.getMapText(this.typeMap, text)
  253. }
  254. },
  255. {
  256. title: '部位',
  257. dataIndex: 'partName',
  258. checked: true,
  259. width: '200px'
  260. },
  261. {
  262. title: '等级',
  263. dataIndex: 'level',
  264. width: '100px',
  265. checked: true,
  266. customRender: (text, record, index) => {
  267. return this.BaseTool.Table.getMapText(this.levelMap, text)
  268. }
  269. },
  270. {
  271. title: '标准内容',
  272. dataIndex: 'requirement',
  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: '250px',
  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. }
  335. }
  336. return getCheckStandardPage(Object.assign(parameter, this.queryParam))
  337. .then(res => {
  338. return res.data
  339. })
  340. },
  341. selectedRowKeys: [],
  342. selectedRows: [],
  343. options: {
  344. alert: {
  345. show: true,
  346. clear: () => {
  347. this.selectedRowKeys = []
  348. }
  349. },
  350. rowSelection: {
  351. selectedRowKeys: this.selectedRowKeys,
  352. onChange: this.onSelectChange
  353. }
  354. },
  355. optionAlertShow: false
  356. }
  357. },
  358. created () {
  359. // 下拉框map
  360. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  361. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  362. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  363. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  364. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  365. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  366. fetchSbTypeTree().then(res => {
  367. this.treeData = res.data
  368. })
  369. this.tableOption()
  370. },
  371. methods: {
  372. addBYTask (record) {
  373. addBYTask({ id: record.id }).then(res => {
  374. this.$refs.table.refresh(true)
  375. })
  376. },
  377. tableOption () {
  378. if (!this.optionAlertShow) {
  379. this.options = {
  380. alert: {
  381. show: true,
  382. clear: () => {
  383. this.selectedRowKeys = []
  384. }
  385. },
  386. rowSelection: {
  387. selectedRowKeys: this.selectedRowKeys,
  388. onChange: this.onSelectChange,
  389. getCheckboxProps: record => ({
  390. props: {
  391. disabled: false,
  392. name: record.id
  393. }
  394. })
  395. }
  396. }
  397. this.optionAlertShow = true
  398. } else {
  399. this.options = {
  400. alert: false,
  401. rowSelection: null
  402. }
  403. this.optionAlertShow = false
  404. }
  405. },
  406. batchDelete (id) {
  407. let ids = []
  408. if (this.BaseTool.String.isBlank(id)) {
  409. const length = this.selectedRows.length
  410. if (length === 0) {
  411. this.$message.info('请选择要删除的记录')
  412. return
  413. }
  414. ids = this.selectedRows.map(item => item.id)
  415. } else {
  416. ids = [id]
  417. }
  418. deleteCheckStandards(ids).then(res => {
  419. this.$message.info('删除成功')
  420. this.handleOk()
  421. this.$refs.table.clearSelected()
  422. })
  423. },
  424. doUpdateNo (record) {
  425. this.confirmLoading = true
  426. updateCheckStandardNo().then(res => {
  427. this.confirmLoading = false
  428. this.$message.info('编码生成成功')
  429. this.handleOk()
  430. this.$refs.table.clearSelected()
  431. })
  432. },
  433. handleEdit (record) {
  434. const modal = this.$refs.baseModal
  435. modal.base(record)
  436. },
  437. handleView (record) {
  438. fetchCheckStandard({ id: record.id }).then(res => {
  439. const modal = this.$refs.detailModal
  440. modal.base(res.data)
  441. })
  442. },
  443. handleViewCheckJob (record) {
  444. this.visible = false
  445. const modal = this.$refs.detailSbCheckJobModal
  446. modal.base(record)
  447. },
  448. handleCopy (record) {
  449. fetchCheckStandard({ id: record.id }).then(res => {
  450. const modal = this.$refs.baseModal
  451. res.data.id = null
  452. modal.base(res.data)
  453. })
  454. },
  455. handleOk () {
  456. this.visible = true
  457. this.$refs.table.refresh()
  458. },
  459. onSelectChange (selectedRowKeys, selectedRows) {
  460. this.selectedRowKeys = selectedRowKeys
  461. this.selectedRows = selectedRows
  462. },
  463. resetSearchForm () {
  464. this.queryParam = {}
  465. this.$refs.table.refresh(true)
  466. },
  467. doImport () {
  468. this.$refs.importModal.base(0)
  469. },
  470. doImportOldVersion () {
  471. this.$refs.importModal.base(1)
  472. },
  473. doImportByUpdate () {
  474. this.$refs.importModal.base(2)
  475. },
  476. doExport () {
  477. const parameter = {
  478. ...this.queryParam
  479. }
  480. exportCheckStandard(parameter).then(file => {
  481. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  482. })
  483. }
  484. }
  485. }
  486. </script>