MeasureSbInfo.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8" v-show="visible">
  4. <a-col :span="24">
  5. <div>
  6. <div class="table-page-search-wrapper">
  7. <a-form layout="inline">
  8. <a-row :gutter="48">
  9. <a-col :md="8" :sm="24">
  10. <a-form-item label="关键字">
  11. <a-input v-model="queryParam.keyword" placeholder="请输入名称"/>
  12. </a-form-item>
  13. </a-col>
  14. <a-col :md="8" :sm="24">
  15. <a-form-item label="设备新号">
  16. <a-input v-model="queryParam.no"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="8" :sm="24">
  20. <a-form-item label="测量设备编号">
  21. <a-input v-model="queryParam.cardNo" />
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="8" :sm="24">
  25. <a-form-item label="使用部门">
  26. <a-input v-model="queryParam.useDept" />
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="8" :sm="24">
  30. <a-form-item label="出厂编号">
  31. <a-input v-model="queryParam.zzh"/>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="管理状态">
  36. <a-select v-model="queryParam.status" placeholder="请选择">
  37. <a-select-option
  38. v-for="(label,value) in statusMap"
  39. :key="value"
  40. :label="label"
  41. :value="parseInt(value)">{{ label }}
  42. </a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="10" :sm="24">
  47. <a-form-item label="有效日期">
  48. <a-range-picker v-model="dateRange" :style="{width: '256px'}" />
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6 || 24" :sm="24">
  52. <span class="table-page-search-submitButtons">
  53. <a-button type="primary" @click="handleOk()">查询</a-button>
  54. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  55. </span>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <div class="table-operator">
  61. <a-button v-if="$auth('sb-infos-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  62. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="upload" @click="doImport">新增导入</a-button>
  63. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="upload" @click="doImportForUpdate">修改导入</a-button>
  64. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  65. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExportMeasure">检定导出</a-button>
  66. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  67. <a-menu slot="overlay">
  68. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  69. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  70. </a-popconfirm>
  71. </a-menu>
  72. <a-button style="margin-left: 8px">
  73. 批量操作 <a-icon type="down" />
  74. </a-button>
  75. </a-dropdown>
  76. </div>
  77. <s-table
  78. ref="table"
  79. size="default"
  80. rowKey="id"
  81. :widthSpace="true"
  82. :columns="columns"
  83. :data="loadData"
  84. :alert="options.alert"
  85. :rowSelection="options.rowSelection"
  86. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  87. showPagination="auto"
  88. >
  89. <span slot="action" slot-scope="record">
  90. <template>
  91. <div>
  92. <a-dropdown>
  93. <a-menu slot="overlay">
  94. <a-menu-item key="0">
  95. <a @click="handleView(record)">查看</a>
  96. </a-menu-item>
  97. <a-menu-item key="1">
  98. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  99. </a-menu-item>
  100. </a-menu>
  101. <a-button> 操作 <a-icon type="down" /> </a-button>
  102. </a-dropdown>
  103. </div>
  104. </template>
  105. </span>
  106. <span slot="status" slot-scope="text">
  107. <badge
  108. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  109. :text="statusMap[text]" />
  110. </span>
  111. </s-table>
  112. </div>
  113. </a-col>
  114. </a-row>
  115. <base-form ref="baseModal" @ok="handleOk"/>
  116. <detail ref="detailModal" @ok="handleOk"/>
  117. <download-modal ref="downloadModal"/>
  118. <import-form-update ref="importModalUpdate" @ok="handleOk"/>
  119. <preview-modal ref="previewModal"/>
  120. <import-form-add ref="importModal" @ok="handleOk"/>
  121. </a-card>
  122. </template>
  123. <script>
  124. import { STable, Ellipsis } from '@/components'
  125. import BaseForm from './modules/BaseForm'
  126. import Detail from './modules/Detail'
  127. import DownloadModal from '@/views/download/DownloadModal'
  128. import PreviewModal from '@/views/preview/PreviewModal'
  129. import {
  130. getSbInfoPage,
  131. deleteSbInfos,
  132. fetchSbInfo,
  133. exportSbInfoMeasure,
  134. exportSbInfoMeasureTwo
  135. } from '@/api/sb/measure'
  136. import { fetchSbTypeTree } from '@/api/sb/type'
  137. import ImportFormAdd from './modules/ImportFormAdd'
  138. import ImportFormUpdate from './modules/ImportFormUpdate'
  139. export default {
  140. name: 'MeasureSbInfoList',
  141. components: {
  142. STable,
  143. Ellipsis,
  144. BaseForm,
  145. Detail,
  146. DownloadModal,
  147. PreviewModal,
  148. ImportFormAdd,
  149. ImportFormUpdate
  150. },
  151. props: {
  152. seatNumber: {
  153. type: Number,
  154. default: null
  155. }
  156. },
  157. data () {
  158. return {
  159. dateRange: [],
  160. deptUserList: [],
  161. // 查询参数
  162. queryParam: {
  163. seatNumber: this.seatNumber
  164. },
  165. depreciationTypeMap: {},
  166. visible: true,
  167. statusMap: {},
  168. measureMap: {},
  169. expandedKeys: [],
  170. selectedKeys: [],
  171. sourceTypeMap: {},
  172. treeData: [],
  173. // 表头
  174. columns: [
  175. {
  176. title: '序号',
  177. dataIndex: 'index',
  178. width: 120,
  179. checked: true,
  180. customRender: (text, record, index) => {
  181. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  182. }
  183. },
  184. {
  185. title: '测量设备编号',
  186. dataIndex: 'cardNo',
  187. width: 150,
  188. checked: true
  189. },
  190. {
  191. title: '设备名称',
  192. checked: true,
  193. width: 200,
  194. dataIndex: 'name'
  195. },
  196. {
  197. title: '出厂编号',
  198. checked: true,
  199. width: 200,
  200. dataIndex: 'zzh'
  201. },
  202. {
  203. title: '规格型号',
  204. checked: true,
  205. width: 200,
  206. dataIndex: 'model'
  207. },
  208. {
  209. title: '要求准确度等级',
  210. dataIndex: 'zz',
  211. width: 150,
  212. checked: true
  213. },
  214. {
  215. title: '使用部门',
  216. checked: true,
  217. width: 200,
  218. dataIndex: 'useDept'
  219. },
  220. {
  221. title: '使用地点',
  222. checked: true,
  223. width: 200,
  224. dataIndex: 'cph'
  225. },
  226. {
  227. title: '准确度等级',
  228. checked: true,
  229. width: 200,
  230. dataIndex: 'fdjxh'
  231. },
  232. {
  233. title: '检定日期',
  234. checked: true,
  235. width: 200,
  236. dataIndex: 'checkDate'
  237. },
  238. {
  239. title: '检定周期',
  240. checked: true,
  241. width: 200,
  242. dataIndex: 'checkPeriod',
  243. customRender: (text, record, index) => {
  244. if (record.checkPeriod == null) {
  245. return '未知'
  246. } else {
  247. return text + '月'
  248. }
  249. }
  250. },
  251. {
  252. title: '有效日期',
  253. dataIndex: 'nextCheckDate',
  254. width: 150,
  255. checked: true
  256. },
  257. {
  258. title: '生产厂商',
  259. dataIndex: 'producerId',
  260. width: 150,
  261. checked: true
  262. },
  263. {
  264. title: '检定单位',
  265. dataIndex: 'dph',
  266. width: 150,
  267. checked: true
  268. },
  269. {
  270. title: '检定人',
  271. dataIndex: 'zaiz',
  272. width: 150,
  273. checked: true
  274. },
  275. {
  276. title: '检定结论',
  277. dataIndex: 'rlType',
  278. width: 150,
  279. checked: true,
  280. customRender: (text, record, index) => {
  281. return this.BaseTool.Object.getField(this.measureMap, text)
  282. }
  283. },
  284. {
  285. title: '是否周检',
  286. dataIndex: 'color',
  287. width: 150,
  288. checked: true,
  289. customRender: (text, record, index) => {
  290. if (text === 0) {
  291. return '否'
  292. } else {
  293. return '是'
  294. }
  295. }
  296. },
  297. {
  298. title: '检定证书编号',
  299. dataIndex: 'sbdh',
  300. width: 150,
  301. checked: true
  302. },
  303. {
  304. title: '检定校准记录',
  305. dataIndex: 'zbh',
  306. width: 150,
  307. checked: true
  308. },
  309. {
  310. title: '预警天数',
  311. dataIndex: 'seatNumber',
  312. width: 150,
  313. checked: true
  314. },
  315. {
  316. title: '是否固定资产',
  317. dataIndex: 'isFinancing',
  318. width: 150,
  319. checked: true,
  320. customRender: (text, record, index) => {
  321. if (text === 0) {
  322. return '否'
  323. } else {
  324. return '是'
  325. }
  326. }
  327. },
  328. {
  329. title: '固定资产编号',
  330. dataIndex: 'financingNo',
  331. width: 150,
  332. checked: true
  333. },
  334. {
  335. title: '设备新号',
  336. dataIndex: 'no',
  337. width: 150,
  338. checked: true
  339. },
  340. {
  341. title: '检定截止',
  342. dataIndex: 'restDay',
  343. width: 100,
  344. fixed: 'right',
  345. checked: true,
  346. customRender: (text, record, index) => {
  347. if (record.nextCheckDate == null) {
  348. return '未知'
  349. } else {
  350. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  351. }
  352. }
  353. },
  354. {
  355. title: '管理状态',
  356. checked: true,
  357. dataIndex: 'status',
  358. width: 100,
  359. fixed: 'right',
  360. scopedSlots: { customRender: 'status' }
  361. },
  362. {
  363. title: '操作',
  364. key: 'action',
  365. checked: true,
  366. fixed: 'right',
  367. align: 'center',
  368. width: '100',
  369. scopedSlots: { customRender: 'action' }
  370. }
  371. ],
  372. // 加载数据方法 必须为 Promise 对象
  373. loadData: parameter => {
  374. parameter = {
  375. ...parameter,
  376. ...this.queryParam,
  377. dataScope: {
  378. sortBy: 'asc',
  379. sortName: 'no'
  380. }
  381. }
  382. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  383. .then(res => {
  384. return res.data
  385. })
  386. },
  387. selectedRowKeys: [],
  388. selectedRows: [],
  389. options: {
  390. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  391. rowSelection: {
  392. selectedRowKeys: this.selectedRowKeys,
  393. onChange: this.onSelectChange
  394. }
  395. },
  396. optionAlertShow: false
  397. }
  398. },
  399. created () {
  400. this.tableOption()
  401. this.measureMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MEASURE_RESULT)
  402. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MEASURE_STATUS)
  403. this.isFinancingMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_FINANCING)
  404. },
  405. methods: {
  406. tableOption () {
  407. this.setTree()
  408. if (!this.optionAlertShow) {
  409. this.options = {
  410. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  411. rowSelection: {
  412. selectedRowKeys: this.selectedRowKeys,
  413. onChange: this.onSelectChange,
  414. getCheckboxProps: record => ({
  415. props: {
  416. disabled: false,
  417. name: record.id
  418. }
  419. })
  420. }
  421. }
  422. this.optionAlertShow = true
  423. } else {
  424. this.options = {
  425. alert: false,
  426. rowSelection: null
  427. }
  428. this.optionAlertShow = false
  429. }
  430. },
  431. batchDelete (id) {
  432. let ids = []
  433. if (this.BaseTool.String.isBlank(id)) {
  434. const length = this.selectedRows.length
  435. if (length === 0) {
  436. this.$message.info('请选择要删除的记录')
  437. return
  438. }
  439. ids = this.selectedRows.map(item => item.id)
  440. } else {
  441. ids = [id]
  442. }
  443. deleteSbInfos(ids).then(res => {
  444. this.$message.info('删除成功')
  445. this.handleOk()
  446. this.$refs.table.clearSelected()
  447. })
  448. },
  449. handleEdit (record) {
  450. fetchSbInfo({ id: record.id }).then(res => {
  451. this.visible = false
  452. const modal = this.$refs.baseModal
  453. modal.base(res.data)
  454. })
  455. },
  456. handleAdd () {
  457. this.visible = false
  458. this.$refs.baseModal.base()
  459. },
  460. handleAddRelate () {
  461. this.visible = false
  462. this.$refs.baseModal.base()
  463. },
  464. handleView (record) {
  465. fetchSbInfo({ id: record.id }).then(res => {
  466. this.visible = false
  467. const modal = this.$refs.detailModal
  468. modal.base(res.data)
  469. })
  470. },
  471. handleOk () {
  472. this.visible = true
  473. this.setTree()
  474. if (this.dateRange != null) {
  475. this.queryParam.nextCheckDateStart = this.dateRange[0]
  476. this.queryParam.nextCheckDateEnd = this.dateRange[1]
  477. this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  478. this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  479. }
  480. this.$refs.table.refresh()
  481. },
  482. onSelectChange (selectedRowKeys, selectedRows) {
  483. this.selectedRowKeys = selectedRowKeys
  484. this.selectedRows = selectedRows
  485. },
  486. resetSearchForm () {
  487. this.queryParam = {
  488. seatNumber: this.seatNumber
  489. }
  490. this.dateRange = []
  491. this.visible = true
  492. this.$refs.table.refresh(true)
  493. },
  494. doExport () {
  495. if (this.dateRange != null) {
  496. this.queryParam.nextCheckDateStart = this.dateRange[0]
  497. this.queryParam.nextCheckDateEnd = this.dateRange[1]
  498. this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  499. this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  500. }
  501. const parameter = {
  502. ...this.queryParam
  503. }
  504. exportSbInfoMeasure(parameter).then(file => {
  505. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  506. })
  507. },
  508. doExportMeasure () {
  509. if (this.dateRange != null) {
  510. this.queryParam.nextCheckDateStart = this.dateRange[0]
  511. this.queryParam.nextCheckDateEnd = this.dateRange[1]
  512. this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  513. this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  514. }
  515. const parameter = {
  516. ...this.queryParam
  517. }
  518. exportSbInfoMeasureTwo(parameter).then(file => {
  519. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  520. })
  521. },
  522. setTree (record = {}) {
  523. fetchSbTypeTree().then(res => {
  524. this.treeData = res.data
  525. })
  526. },
  527. onSelect: function (selectedKeys, info) {
  528. this.selectedKeys = selectedKeys
  529. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  530. this.$refs.table.refresh(true)
  531. },
  532. onExpand (expandedKeys) {
  533. this.expandedKeys = expandedKeys
  534. this.autoExpandParent = false
  535. },
  536. doImport () {
  537. this.$refs.importModal.base(null, null)
  538. },
  539. doImportForUpdate () {
  540. this.$refs.importModalUpdate.base(null, null)
  541. }
  542. }
  543. }
  544. </script>