CheckStandard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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
  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">
  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()">新增
  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-divider type="vertical"/>
  147. <a v-if="($auth('check-spot-standards-edit')||$auth('check-polling-standards-edit'))" @click="handleEdit(record)">修改</a>
  148. <a-divider type="vertical"/>
  149. <a-popconfirm
  150. v-if="($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))"
  151. title="是否要删除该条数据?"
  152. @confirm="batchDelete(record.id)">
  153. <a>删除</a>
  154. </a-popconfirm>
  155. <a-divider type="vertical" />
  156. <a @click="handleCopy(record)">复制</a>
  157. </template>
  158. </span>
  159. </s-table>
  160. </div>
  161. <detail-standard-check-job ref="detailSbCheckJobModal" @ok="handleOk"/>
  162. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  163. <detail ref="detailModal"/>
  164. <import-form-add ref="importModal" @ok="handleOk"/>
  165. </a-card>
  166. </template>
  167. <script>
  168. import { STable, Ellipsis } from '@/components'
  169. import BaseForm from './modules/BaseForm'
  170. import Detail from './modules/Detail'
  171. import ImportFormAdd from './modules/ImportFormAdd'
  172. import {
  173. getCheckStandardPage,
  174. deleteCheckStandards,
  175. updateCheckStandardNo,
  176. fetchCheckStandard,
  177. exportCheckStandard
  178. } from '@/api/check/checkstandard'
  179. import DetailStandardCheckJob from '@/views/check/checkjob/modules/DetailStandardCheckJob'
  180. import { fetchSbTypeTree } from '@/api/sb/type'
  181. export default {
  182. name: 'CheckStandardList',
  183. components: {
  184. STable,
  185. Ellipsis,
  186. BaseForm,
  187. Detail,
  188. ImportFormAdd,
  189. DetailStandardCheckJob
  190. },
  191. props: {
  192. /**
  193. * 检查类型: 1-点检 2-巡检
  194. */
  195. checkType: {
  196. type: Number,
  197. default: 1
  198. }
  199. },
  200. data () {
  201. return {
  202. // 查询参数
  203. visible: true,
  204. confirmLoading: false,
  205. queryParam: {
  206. type: this.checkType
  207. },
  208. // 表头
  209. columns: [
  210. {
  211. title: '序号',
  212. dataIndex: 'index',
  213. width: '100px',
  214. checked: true,
  215. customRender: (text, record, index) => {
  216. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  217. }
  218. },
  219. {
  220. title: '设备新号',
  221. dataIndex: 'sbNo',
  222. checked: true,
  223. width: '100px'
  224. },
  225. {
  226. title: '设备名称',
  227. dataIndex: 'sbName',
  228. checked: true,
  229. width: '150px'
  230. },
  231. {
  232. title: '标准编码',
  233. dataIndex: 'no',
  234. checked: true,
  235. width: '150px'
  236. },
  237. {
  238. title: '部位',
  239. dataIndex: 'partName',
  240. checked: true,
  241. width: '200px'
  242. },
  243. {
  244. title: '维护等级',
  245. dataIndex: 'level',
  246. width: '100px',
  247. checked: true,
  248. customRender: (text, record, index) => {
  249. return this.BaseTool.Table.getMapText(this.levelMap, text)
  250. }
  251. },
  252. {
  253. title: '标准内容',
  254. dataIndex: 'requirement',
  255. checked: true,
  256. width: '250px',
  257. customRender: (text, record, index) => {
  258. if (text != null) {
  259. if (text.length > 40) {
  260. return text.slice(0, 40)
  261. } else {
  262. return text
  263. }
  264. } else {
  265. return text
  266. }
  267. }
  268. },
  269. {
  270. title: '计划周期',
  271. dataIndex: 'period',
  272. width: '100px',
  273. checked: true,
  274. customRender: (text, record, index) => {
  275. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  276. }
  277. },
  278. {
  279. title: '预计下次执行日期',
  280. dataIndex: 'nextDate',
  281. checked: true,
  282. width: '200px'
  283. },
  284. {
  285. title: '上次执行日期',
  286. dataIndex: 'lastDate',
  287. fixed: 'right',
  288. checked: true,
  289. width: '200px'
  290. },
  291. {
  292. title: '操作',
  293. key: 'action',
  294. width: '250px',
  295. checked: true,
  296. fixed: 'right',
  297. align: 'center',
  298. scopedSlots: { customRender: 'action' }
  299. }
  300. ],
  301. // 下拉框map
  302. actionTypeMap: {},
  303. typeMap: {},
  304. enableMap: {},
  305. periodTypeMap: {},
  306. levelMap: {},
  307. sbLevelMap: {},
  308. treeData: [],
  309. checkUserTypeMap: {},
  310. // 加载数据方法 必须为 Promise 对象
  311. loadData: parameter => {
  312. parameter = {
  313. ...parameter,
  314. ...this.queryParam,
  315. dataScope: {
  316. }
  317. }
  318. return getCheckStandardPage(Object.assign(parameter, this.queryParam))
  319. .then(res => {
  320. return res.data
  321. })
  322. },
  323. selectedRowKeys: [],
  324. selectedRows: [],
  325. options: {
  326. alert: {
  327. show: true,
  328. clear: () => {
  329. this.selectedRowKeys = []
  330. }
  331. },
  332. rowSelection: {
  333. selectedRowKeys: this.selectedRowKeys,
  334. onChange: this.onSelectChange
  335. }
  336. },
  337. optionAlertShow: false
  338. }
  339. },
  340. created () {
  341. // 下拉框map
  342. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  343. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  344. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  345. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  346. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  347. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  348. fetchSbTypeTree().then(res => {
  349. this.treeData = res.data
  350. })
  351. this.tableOption()
  352. },
  353. methods: {
  354. tableOption () {
  355. if (!this.optionAlertShow) {
  356. this.options = {
  357. alert: {
  358. show: true,
  359. clear: () => {
  360. this.selectedRowKeys = []
  361. }
  362. },
  363. rowSelection: {
  364. selectedRowKeys: this.selectedRowKeys,
  365. onChange: this.onSelectChange,
  366. getCheckboxProps: record => ({
  367. props: {
  368. disabled: false,
  369. name: record.id
  370. }
  371. })
  372. }
  373. }
  374. this.optionAlertShow = true
  375. } else {
  376. this.options = {
  377. alert: false,
  378. rowSelection: null
  379. }
  380. this.optionAlertShow = false
  381. }
  382. },
  383. batchDelete (id) {
  384. let ids = []
  385. if (this.BaseTool.String.isBlank(id)) {
  386. const length = this.selectedRows.length
  387. if (length === 0) {
  388. this.$message.info('请选择要删除的记录')
  389. return
  390. }
  391. ids = this.selectedRows.map(item => item.id)
  392. } else {
  393. ids = [id]
  394. }
  395. deleteCheckStandards(ids).then(res => {
  396. this.$message.info('删除成功')
  397. this.handleOk()
  398. this.$refs.table.clearSelected()
  399. })
  400. },
  401. doUpdateNo (record) {
  402. this.confirmLoading = true
  403. updateCheckStandardNo().then(res => {
  404. this.confirmLoading = false
  405. this.$message.info('编码生成成功')
  406. this.handleOk()
  407. this.$refs.table.clearSelected()
  408. })
  409. },
  410. handleEdit (record) {
  411. const modal = this.$refs.baseModal
  412. modal.base(record)
  413. },
  414. handleView (record) {
  415. fetchCheckStandard({ id: record.id }).then(res => {
  416. const modal = this.$refs.detailModal
  417. modal.base(res.data)
  418. })
  419. },
  420. handleViewCheckJob (record) {
  421. this.visible = false
  422. const modal = this.$refs.detailSbCheckJobModal
  423. modal.base(record)
  424. },
  425. handleCopy (record) {
  426. fetchCheckStandard({ id: record.id }).then(res => {
  427. const modal = this.$refs.baseModal
  428. res.data.id = null
  429. modal.base(res.data)
  430. })
  431. },
  432. handleOk () {
  433. this.visible = true
  434. this.$refs.table.refresh()
  435. },
  436. onSelectChange (selectedRowKeys, selectedRows) {
  437. this.selectedRowKeys = selectedRowKeys
  438. this.selectedRows = selectedRows
  439. },
  440. resetSearchForm () {
  441. this.queryParam = {}
  442. this.$refs.table.refresh(true)
  443. },
  444. doImport () {
  445. this.$refs.importModal.base(0)
  446. },
  447. doImportOldVersion () {
  448. this.$refs.importModal.base(1)
  449. },
  450. doImportByUpdate () {
  451. this.$refs.importModal.base(2)
  452. },
  453. doExport () {
  454. const parameter = {
  455. ...this.queryParam
  456. }
  457. exportCheckStandard(parameter).then(file => {
  458. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  459. })
  460. }
  461. }
  462. }
  463. </script>