MeasureSbInfoSelectModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="1300"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-card :bordered="false">
  11. <div class="table-page-search-wrapper">
  12. <a-form layout="inline">
  13. <a-row :gutter="48">
  14. <a-col :md="8" :sm="24">
  15. <a-form-item label="关键字">
  16. <a-input v-model="queryParam.keyword" placeholder="请输入名称/编码"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="8 || 24" :sm="24">
  20. <span class="table-page-search-submitButtons">
  21. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  22. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  23. </span>
  24. </a-col>
  25. </a-row>
  26. </a-form>
  27. </div>
  28. <div class="table-operator">
  29. </div>
  30. <s-table
  31. ref="table"
  32. size="default"
  33. rowKey="id"
  34. :columns="columns"
  35. :data="loadData"
  36. :alert="options.alert"
  37. :customRow="options.customRow"
  38. :rowSelection="options.rowSelection"
  39. :scroll="{ x: 1300, y: BaseTool.Constant.scrollY }"
  40. showPagination="auto"
  41. >
  42. <span slot="action" slot-scope="record">
  43. <template>
  44. </template>
  45. </span>
  46. <span slot="status" slot-scope="text">
  47. <badge :status="DictCache.COLOR.SB_INFO_STATUS[text]" :text="statusMap[text]" />
  48. </span>
  49. </s-table>
  50. </a-card>
  51. <template slot="footer">
  52. <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">取消</a-button>
  53. <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">选择</a-button>
  54. </template>
  55. </a-modal>
  56. </template>
  57. <script>
  58. import { STable, Ellipsis } from '@/components'
  59. import { getSbInfoPage, getSbInfoTree } from '@/api/sb/measure'
  60. export default {
  61. name: 'MeasureSbInfoSelectModal',
  62. components: {
  63. STable,
  64. Ellipsis
  65. },
  66. props: {
  67. type: {
  68. type: String,
  69. default: 'radio'
  70. },
  71. selectedRowKey: {
  72. type: Array,
  73. default: () => {
  74. return []
  75. }
  76. },
  77. selectedRow: {
  78. type: Array,
  79. default: () => {
  80. return []
  81. }
  82. }
  83. },
  84. data () {
  85. return {
  86. confirmLoading: false,
  87. mdl: {},
  88. modalTitle: null,
  89. visible: false,
  90. // 查询参数
  91. queryParam: {
  92. },
  93. extraQueryParam: {
  94. },
  95. depreciationTypeMap: {},
  96. levelMap: {},
  97. statusMap: {},
  98. unitMap: {},
  99. useTypeMap: {},
  100. sourceTypeMap: {},
  101. // 表头
  102. columns: [
  103. {
  104. title: '序号',
  105. dataIndex: 'index',
  106. width: 120,
  107. checked: true,
  108. customRender: (text, record, index) => {
  109. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  110. }
  111. },
  112. {
  113. title: '测量设备编号',
  114. dataIndex: 'cardNo',
  115. width: 150,
  116. checked: true
  117. },
  118. {
  119. title: '设备名称',
  120. checked: true,
  121. width: 200,
  122. dataIndex: 'name'
  123. },
  124. {
  125. title: '出厂编号',
  126. checked: true,
  127. width: 200,
  128. dataIndex: 'zzh'
  129. },
  130. {
  131. title: '规格型号',
  132. checked: true,
  133. width: 200,
  134. dataIndex: 'model'
  135. },
  136. {
  137. title: '要求准确度等级',
  138. dataIndex: 'zz',
  139. width: 150,
  140. checked: true
  141. },
  142. {
  143. title: '使用部门',
  144. checked: true,
  145. width: 200,
  146. dataIndex: 'useDept'
  147. },
  148. {
  149. title: '使用地点',
  150. checked: true,
  151. width: 200,
  152. dataIndex: 'cph'
  153. },
  154. {
  155. title: '准确度等级',
  156. checked: true,
  157. width: 200,
  158. dataIndex: 'fdjxh'
  159. },
  160. {
  161. title: '检定日期',
  162. checked: true,
  163. width: 200,
  164. dataIndex: 'checkDate'
  165. },
  166. {
  167. title: '检定周期',
  168. checked: true,
  169. width: 200,
  170. dataIndex: 'checkPeriod',
  171. customRender: (text, record, index) => {
  172. if (record.checkPeriod == null) {
  173. return '未知'
  174. } else {
  175. return text + '月'
  176. }
  177. }
  178. },
  179. {
  180. title: '有效日期',
  181. dataIndex: 'nextCheckDate',
  182. width: 150,
  183. checked: true
  184. },
  185. {
  186. title: '生产厂商',
  187. dataIndex: 'producerId',
  188. width: 150,
  189. checked: true
  190. },
  191. {
  192. title: '检定单位',
  193. dataIndex: 'dph',
  194. width: 150,
  195. checked: true
  196. },
  197. {
  198. title: '检定人',
  199. dataIndex: 'zaiz',
  200. width: 150,
  201. checked: true
  202. },
  203. {
  204. title: '检定结论',
  205. dataIndex: 'rlType',
  206. width: 150,
  207. checked: true,
  208. customRender: (text, record, index) => {
  209. return this.BaseTool.Object.getField(this.measureMap, text)
  210. }
  211. },
  212. {
  213. title: '是否周检',
  214. dataIndex: 'color',
  215. width: 150,
  216. checked: true,
  217. customRender: (text, record, index) => {
  218. if (text === 0) {
  219. return '否'
  220. } else {
  221. return '是'
  222. }
  223. }
  224. },
  225. {
  226. title: '检定证书编号',
  227. dataIndex: 'sbdh',
  228. width: 150,
  229. checked: true
  230. },
  231. {
  232. title: '检定校准记录',
  233. dataIndex: 'zbh',
  234. width: 150,
  235. checked: true
  236. },
  237. {
  238. title: '预警天数',
  239. dataIndex: 'seatNumber',
  240. width: 150,
  241. checked: true
  242. },
  243. {
  244. title: '是否固定资产',
  245. dataIndex: 'isFinancing',
  246. width: 150,
  247. checked: true,
  248. customRender: (text, record, index) => {
  249. if (text === 0) {
  250. return '否'
  251. } else {
  252. return '是'
  253. }
  254. }
  255. },
  256. {
  257. title: '固定资产编号',
  258. dataIndex: 'financingNo',
  259. width: 150,
  260. checked: true
  261. },
  262. {
  263. title: '设备新号',
  264. dataIndex: 'no',
  265. width: 150,
  266. checked: true
  267. },
  268. {
  269. title: '检定截止',
  270. dataIndex: 'restDay',
  271. width: 100,
  272. fixed: 'right',
  273. checked: true,
  274. customRender: (text, record, index) => {
  275. if (record.nextCheckDate == null) {
  276. return '未知'
  277. } else {
  278. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  279. }
  280. }
  281. },
  282. {
  283. title: '管理状态',
  284. checked: true,
  285. dataIndex: 'status',
  286. width: 100,
  287. fixed: 'right',
  288. scopedSlots: { customRender: 'status' }
  289. },
  290. {
  291. title: '操作',
  292. key: 'action',
  293. checked: true,
  294. fixed: 'right',
  295. align: 'center',
  296. width: '100',
  297. scopedSlots: { customRender: 'action' }
  298. }
  299. ],
  300. // 加载数据方法 必须为 Promise 对象
  301. loadData: parameter => {
  302. parameter = {
  303. ...parameter,
  304. ...this.queryParam,
  305. ...this.extraQueryParam,
  306. dataScope: {
  307. sortBy: 'asc',
  308. sortName: 'no'
  309. }
  310. }
  311. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  312. .then(res => {
  313. return res.data
  314. })
  315. },
  316. selectedRowKeys: [],
  317. selectedRows: [],
  318. options: {
  319. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  320. rowSelection: {
  321. selectedRowKeys: this.selectedRowKeys,
  322. onChange: this.onSelectChange
  323. }
  324. },
  325. optionAlertShow: true,
  326. isCreated: false
  327. }
  328. },
  329. created () {
  330. this.tableOption()
  331. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  332. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  333. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  334. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  335. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  336. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_UES_TYPE)
  337. },
  338. methods: {
  339. tableOption () {
  340. if (!this.optionAlertShow) {
  341. this.options = {
  342. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  343. rowSelection: {
  344. selectedRowKeys: this.selectedRowKeys,
  345. onChange: this.onSelectChange,
  346. type: this.type,
  347. getCheckboxProps: record => ({
  348. props: {
  349. disabled: false,
  350. name: record.id
  351. }
  352. })
  353. },
  354. customRow: (record) => {
  355. return {
  356. on: { // 事件
  357. click: (event) => { // 点击行
  358. // 选择对象
  359. this.mySelect([record.id], [record])
  360. },
  361. dblclick: (event) => {
  362. this.mySelect([record.id], [record])
  363. this.handleSelect()
  364. }
  365. }
  366. }
  367. }
  368. }
  369. this.optionAlertShow = true
  370. } else {
  371. this.options = {
  372. alert: false,
  373. rowSelection: null
  374. }
  375. this.optionAlertShow = false
  376. }
  377. },
  378. handleOk () {
  379. this.$refs.table.refresh()
  380. },
  381. onSelectChange (selectedRowKeys, selectedRows) {
  382. this.selectedRowKeys = selectedRowKeys
  383. this.selectedRows = selectedRows
  384. },
  385. resetSearchForm () {
  386. this.queryParam = {
  387. }
  388. this.$refs.table.refresh(true)
  389. },
  390. base (record, queryParam = {}) {
  391. this.visible = true
  392. this.modalTitle = '选择设备'
  393. this.extraQueryParam = queryParam
  394. if (this.isCreated) {
  395. this.$refs.table.clearSelected()
  396. this.options.rowSelection.type = this.type
  397. this.handleOk()
  398. } else {
  399. this.tableOption()
  400. this.isCreated = true
  401. }
  402. // this.mySelect(this.selectedRowKeys, this.selectedRows)
  403. },
  404. handleCancel () {
  405. this.visible = false
  406. this.confirmLoading = false
  407. },
  408. handleSelect () {
  409. if (this.selectedRowKeys.length === 0) {
  410. this.$message.warn('请至少选择一项信息')
  411. } else {
  412. this.confirmLoading = true
  413. this.$emit('selected', this.selectedRowKeys, this.selectedRows)
  414. this.confirmLoading = false
  415. this.visible = false
  416. }
  417. },
  418. mySelect (selectedRowKeys, selectedRows) {
  419. this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
  420. this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
  421. }
  422. }
  423. }
  424. </script>