CheckStandard.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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 || 24" :sm="24">
  23. <span class="table-page-search-submitButtons">
  24. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  25. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  26. </span>
  27. </a-col>
  28. </a-row>
  29. </a-form>
  30. </div>
  31. <div class="table-operator">
  32. <a-button
  33. v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))"
  34. type="primary"
  35. icon="plus"
  36. @click="$refs.baseModal.base()">新增
  37. </a-button>
  38. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  39. <a-icon type="upload"/>
  40. 新增导入
  41. </a-button>
  42. <!-- <a-button style="margin-left:8px;" type="primary" @click="doImportOldVersion">
  43. <a-icon type="upload"/>
  44. 老版本导入
  45. </a-button>-->
  46. <a-button style="margin-left:8px;" type="primary" @click="doImportByUpdate">
  47. <a-icon type="upload"/>
  48. 修改导入
  49. </a-button>
  50. <a-button
  51. style="margin-left: 8px"
  52. v-if="($auth('check-spot-standards-export')||$auth('check-polling-standards-export'))"
  53. type="primary"
  54. icon="download"
  55. @click="doExport">导出
  56. </a-button>
  57. <!-- <a-button :confirmLoading="confirmLoading" style="margin-left:8px;" type="primary" @click="doUpdateNo">
  58. <a-icon type="upload"/>
  59. 初始化编码
  60. </a-button>-->
  61. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))">
  62. <a-menu slot="overlay">
  63. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  64. <a-menu-item key="1">
  65. <a-icon type="delete"/>
  66. <a>删除</a></a-menu-item>
  67. </a-popconfirm>
  68. </a-menu>
  69. <a-button style="margin-left: 8px">
  70. 批量操作
  71. <a-icon type="down"/>
  72. </a-button>
  73. </a-dropdown>
  74. </div>
  75. <s-table
  76. ref="table"
  77. size="default"
  78. rowKey="id"
  79. :columns="columns"
  80. :scroll="{x: 1500, y: BaseTool.Constant.scrollY }"
  81. :data="loadData"
  82. :alert="options.alert"
  83. :rowSelection="options.rowSelection"
  84. showPagination="auto"
  85. >
  86. <span slot="enable" slot-scope="text">
  87. <badge
  88. :status="DictCache.COLOR.YES_NO[text]"
  89. :text="enableMap[text]" />
  90. </span>
  91. <span slot="action" slot-scope="record">
  92. <template>
  93. <a @click="handleView(record)">查看</a>
  94. <a-divider type="vertical"/>
  95. <a @click="handleViewCheckJob(record)">保养任务</a>
  96. <a-divider type="vertical"/>
  97. <a v-if="($auth('check-spot-standards-edit')||$auth('check-polling-standards-edit'))" @click="handleEdit(record)">修改</a>
  98. <a-divider type="vertical"/>
  99. <a-popconfirm
  100. v-if="($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))"
  101. title="是否要删除该条数据?"
  102. @confirm="batchDelete(record.id)">
  103. <a>删除</a>
  104. </a-popconfirm>
  105. <a-divider type="vertical" />
  106. <a @click="handleCopy(record)">复制</a>
  107. </template>
  108. </span>
  109. </s-table>
  110. </div>
  111. <detail-standard-check-job ref="detailSbCheckJobModal" @ok="handleOk"/>
  112. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  113. <detail ref="detailModal"/>
  114. <import-form-add ref="importModal" @ok="handleOk"/>
  115. </a-card>
  116. </template>
  117. <script>
  118. import { STable, Ellipsis } from '@/components'
  119. import BaseForm from './modules/BaseForm'
  120. import Detail from './modules/Detail'
  121. import ImportFormAdd from './modules/ImportFormAdd'
  122. import {
  123. getCheckStandardPage,
  124. deleteCheckStandards,
  125. updateCheckStandardNo,
  126. fetchCheckStandard,
  127. exportCheckStandard
  128. } from '@/api/check/checkstandard'
  129. import DetailStandardCheckJob from '@/views/check/checkjob/modules/DetailStandardCheckJob'
  130. export default {
  131. name: 'CheckStandardList',
  132. components: {
  133. STable,
  134. Ellipsis,
  135. BaseForm,
  136. Detail,
  137. ImportFormAdd,
  138. DetailStandardCheckJob
  139. },
  140. props: {
  141. /**
  142. * 检查类型: 1-点检 2-巡检
  143. */
  144. checkType: {
  145. type: Number,
  146. default: 1
  147. }
  148. },
  149. data () {
  150. return {
  151. // 查询参数
  152. visible: true,
  153. confirmLoading: false,
  154. queryParam: {
  155. type: this.checkType
  156. },
  157. // 表头
  158. columns: [
  159. {
  160. title: '序号',
  161. dataIndex: 'index',
  162. width: '100px',
  163. checked: true,
  164. customRender: (text, record, index) => {
  165. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  166. }
  167. },
  168. {
  169. title: '设备新号',
  170. dataIndex: 'sbNo',
  171. checked: true,
  172. width: '100px'
  173. },
  174. {
  175. title: '设备名称',
  176. dataIndex: 'sbName',
  177. checked: true,
  178. width: '150px'
  179. },
  180. {
  181. title: '标准编码',
  182. dataIndex: 'no',
  183. checked: true,
  184. width: '150px'
  185. },
  186. {
  187. title: '部位',
  188. dataIndex: 'partName',
  189. checked: true,
  190. width: '200px'
  191. },
  192. {
  193. title: '维护等级',
  194. dataIndex: 'level',
  195. width: '100px',
  196. checked: true,
  197. customRender: (text, record, index) => {
  198. return this.BaseTool.Table.getMapText(this.levelMap, text)
  199. }
  200. },
  201. {
  202. title: '标准内容',
  203. dataIndex: 'requirement',
  204. checked: true,
  205. width: '250px',
  206. customRender: (text, record, index) => {
  207. if (text != null) {
  208. if (text.length > 40) {
  209. return text.slice(0, 40)
  210. } else {
  211. return text
  212. }
  213. } else {
  214. return text
  215. }
  216. }
  217. },
  218. {
  219. title: '计划周期',
  220. dataIndex: 'period',
  221. width: '100px',
  222. checked: true,
  223. customRender: (text, record, index) => {
  224. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  225. }
  226. },
  227. {
  228. title: '预计下次执行日期',
  229. dataIndex: 'nextDate',
  230. checked: true,
  231. width: '200px'
  232. },
  233. {
  234. title: '上次执行日期',
  235. dataIndex: 'lastDate',
  236. fixed: 'right',
  237. checked: true,
  238. width: '200px'
  239. },
  240. {
  241. title: '操作',
  242. key: 'action',
  243. width: '250px',
  244. checked: true,
  245. fixed: 'right',
  246. align: 'center',
  247. scopedSlots: { customRender: 'action' }
  248. }
  249. ],
  250. // 下拉框map
  251. actionTypeMap: {},
  252. typeMap: {},
  253. enableMap: {},
  254. periodTypeMap: {},
  255. levelMap: {},
  256. checkUserTypeMap: {},
  257. // 加载数据方法 必须为 Promise 对象
  258. loadData: parameter => {
  259. parameter = {
  260. ...parameter,
  261. ...this.queryParam,
  262. dataScope: {
  263. }
  264. }
  265. return getCheckStandardPage(Object.assign(parameter, this.queryParam))
  266. .then(res => {
  267. return res.data
  268. })
  269. },
  270. selectedRowKeys: [],
  271. selectedRows: [],
  272. options: {
  273. alert: {
  274. show: true,
  275. clear: () => {
  276. this.selectedRowKeys = []
  277. }
  278. },
  279. rowSelection: {
  280. selectedRowKeys: this.selectedRowKeys,
  281. onChange: this.onSelectChange
  282. }
  283. },
  284. optionAlertShow: false
  285. }
  286. },
  287. created () {
  288. // 下拉框map
  289. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  290. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  291. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  292. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  293. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  294. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  295. this.tableOption()
  296. },
  297. methods: {
  298. tableOption () {
  299. if (!this.optionAlertShow) {
  300. this.options = {
  301. alert: {
  302. show: true,
  303. clear: () => {
  304. this.selectedRowKeys = []
  305. }
  306. },
  307. rowSelection: {
  308. selectedRowKeys: this.selectedRowKeys,
  309. onChange: this.onSelectChange,
  310. getCheckboxProps: record => ({
  311. props: {
  312. disabled: false,
  313. name: record.id
  314. }
  315. })
  316. }
  317. }
  318. this.optionAlertShow = true
  319. } else {
  320. this.options = {
  321. alert: false,
  322. rowSelection: null
  323. }
  324. this.optionAlertShow = false
  325. }
  326. },
  327. batchDelete (id) {
  328. let ids = []
  329. if (this.BaseTool.String.isBlank(id)) {
  330. const length = this.selectedRows.length
  331. if (length === 0) {
  332. this.$message.info('请选择要删除的记录')
  333. return
  334. }
  335. ids = this.selectedRows.map(item => item.id)
  336. } else {
  337. ids = [id]
  338. }
  339. deleteCheckStandards(ids).then(res => {
  340. this.$message.info('删除成功')
  341. this.handleOk()
  342. this.$refs.table.clearSelected()
  343. })
  344. },
  345. doUpdateNo (record) {
  346. this.confirmLoading = true
  347. updateCheckStandardNo().then(res => {
  348. this.confirmLoading = false
  349. this.$message.info('编码生成成功')
  350. this.handleOk()
  351. this.$refs.table.clearSelected()
  352. })
  353. },
  354. handleEdit (record) {
  355. const modal = this.$refs.baseModal
  356. modal.base(record)
  357. },
  358. handleView (record) {
  359. fetchCheckStandard({ id: record.id }).then(res => {
  360. const modal = this.$refs.detailModal
  361. modal.base(res.data)
  362. })
  363. },
  364. handleViewCheckJob (record) {
  365. this.visible = false
  366. const modal = this.$refs.detailSbCheckJobModal
  367. modal.base(record)
  368. },
  369. handleCopy (record) {
  370. fetchCheckStandard({ id: record.id }).then(res => {
  371. const modal = this.$refs.baseModal
  372. res.data.id = null
  373. modal.base(res.data)
  374. })
  375. },
  376. handleOk () {
  377. this.visible = true
  378. this.$refs.table.refresh()
  379. },
  380. onSelectChange (selectedRowKeys, selectedRows) {
  381. this.selectedRowKeys = selectedRowKeys
  382. this.selectedRows = selectedRows
  383. },
  384. resetSearchForm () {
  385. this.queryParam = {}
  386. this.$refs.table.refresh(true)
  387. },
  388. doImport () {
  389. this.$refs.importModal.base(0)
  390. },
  391. doImportOldVersion () {
  392. this.$refs.importModal.base(1)
  393. },
  394. doImportByUpdate () {
  395. this.$refs.importModal.base(2)
  396. },
  397. doExport () {
  398. const parameter = {
  399. ...this.queryParam
  400. }
  401. exportCheckStandard(parameter).then(file => {
  402. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  403. })
  404. }
  405. }
  406. }
  407. </script>