MeasureLog.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="6" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model.trim="queryParam.keyword" placeholder="设备名称/设备编号/计量设备编号"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="6" :sm="24">
  12. <a-form-item label="起始日期">
  13. <a-date-picker
  14. v-model="queryParam.searchStartTime"
  15. style="width: 100%"
  16. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  17. />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="结束日期">
  22. <a-date-picker
  23. v-model="queryParam.searchEndTime"
  24. style="width: 100%"
  25. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  26. />
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="8 || 24" :sm="24">
  30. <span class="table-page-search-submitButtons">
  31. <a-button type="primary" @click="handleOk">查询</a-button>
  32. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  33. </span>
  34. </a-col>
  35. </a-row>
  36. </a-form>
  37. </div>
  38. <div class="table-operator" style="margin-bottom: 8px;">
  39. <a-button
  40. v-if="($auth('check-spot-standards-add') || $auth('check-polling-standards-add'))"
  41. type="primary"
  42. icon="plus"
  43. @click="$refs.baseModal.base()">新增
  44. </a-button>
  45. <a-button
  46. style="margin-left: 8px"
  47. v-if="($auth('check-spot-standards-export')||$auth('check-polling-standards-export'))"
  48. type="primary"
  49. icon="download"
  50. @click="doExport">导出
  51. </a-button>
  52. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))">
  53. <a-menu slot="overlay">
  54. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  55. <a-menu-item key="1">
  56. <a-icon type="delete"/>
  57. <a>删除</a></a-menu-item>
  58. </a-popconfirm>
  59. </a-menu>
  60. <a-button style="margin-left: 8px">
  61. 批量操作
  62. <a-icon type="down"/>
  63. </a-button>
  64. </a-dropdown>
  65. </div>
  66. <s-table
  67. ref="table"
  68. size="default"
  69. rowKey="id"
  70. :columns="columns"
  71. :data="loadData"
  72. :alert="options.alert"
  73. :rowSelection="options.rowSelection"
  74. showPagination="auto"
  75. >
  76. <span slot="enable" slot-scope="text">
  77. <badge
  78. :status="DictCache.COLOR.YES_NO[text]"
  79. :text="enableMap[text]" />
  80. </span>
  81. <span slot="action" slot-scope="record">
  82. <template>
  83. <a @click="handleView(record)">查看</a>
  84. <a-divider type="vertical"/>
  85. <a v-if="($auth('check-spot-standards-edit')||$auth('check-polling-standards-edit'))" @click="handleEdit(record)">修改</a>
  86. <a-divider type="vertical"/>
  87. <a-popconfirm
  88. v-if="($auth('check-spot-standards-del')||$auth('check-polling-standards-del'))"
  89. title="是否要删除该条数据?"
  90. @confirm="batchDelete(record.id)">
  91. <a>删除</a>
  92. </a-popconfirm>
  93. </template>
  94. </span>
  95. </s-table>
  96. <base-form ref="baseModal" @ok="handleOk"/>
  97. <detail ref="detailModal"/>
  98. </a-card>
  99. </template>
  100. <script>
  101. import { STable, Ellipsis } from '@/components'
  102. import BaseForm from './modules/BaseForm'
  103. import Detail from './modules/Detail'
  104. import {
  105. getCheckStandardPage,
  106. deleteCheckStandards,
  107. exportCheckStandard, fetchCheckStandard
  108. } from '@/api/sb/measurelog'
  109. export default {
  110. name: 'SbMeasureLogList',
  111. components: {
  112. STable,
  113. Ellipsis,
  114. BaseForm,
  115. Detail
  116. },
  117. props: {
  118. type: {
  119. type: Number,
  120. default: 1
  121. }
  122. },
  123. data () {
  124. return {
  125. // 查询参数
  126. queryParam: {
  127. searchStartTime: null,
  128. searchEndTime: null,
  129. type: this.type
  130. },
  131. // 表头
  132. columns: [
  133. {
  134. title: '序号',
  135. dataIndex: 'index',
  136. customRender: (text, record, index) => {
  137. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  138. }
  139. },
  140. {
  141. title: '计量设备编号',
  142. dataIndex: 'cardNo'
  143. },
  144. {
  145. title: '设备名称',
  146. dataIndex: 'sbName'
  147. },
  148. {
  149. title: '设备型号',
  150. dataIndex: 'sbModel'
  151. },
  152. {
  153. title: '出厂编号',
  154. dataIndex: 'sbZzh'
  155. },
  156. {
  157. title: '设备新号',
  158. dataIndex: 'sbNo'
  159. },
  160. {
  161. title: '检定日期',
  162. dataIndex: 'lastDate'
  163. },
  164. {
  165. title: '检定人',
  166. dataIndex: 'name'
  167. },
  168. {
  169. title: '检定单位',
  170. dataIndex: 'dph'
  171. },
  172. {
  173. title: '检定编号',
  174. dataIndex: 'no'
  175. },
  176. {
  177. title: '备注',
  178. dataIndex: 'requirement'
  179. },
  180. {
  181. title: '操作',
  182. key: 'action',
  183. width: '200px',
  184. align: 'center',
  185. scopedSlots: { customRender: 'action' }
  186. }
  187. ],
  188. // 下拉框map
  189. typeMap: {},
  190. enableMap: {},
  191. // 加载数据方法 必须为 Promise 对象
  192. loadData: parameter => {
  193. parameter = {
  194. ...parameter,
  195. ...this.queryParam,
  196. dataScope: {
  197. }
  198. }
  199. return getCheckStandardPage(Object.assign(parameter, this.queryParam))
  200. .then(res => {
  201. return res.data
  202. })
  203. },
  204. selectedRowKeys: [],
  205. selectedRows: [],
  206. options: {
  207. alert: {
  208. show: true,
  209. clear: () => {
  210. this.selectedRowKeys = []
  211. }
  212. },
  213. rowSelection: {
  214. selectedRowKeys: this.selectedRowKeys,
  215. onChange: this.onSelectChange
  216. }
  217. },
  218. optionAlertShow: false
  219. }
  220. },
  221. created () {
  222. // 下拉框map
  223. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  224. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  225. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  226. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  227. this.tableOption()
  228. },
  229. methods: {
  230. tableOption () {
  231. if (!this.optionAlertShow) {
  232. this.options = {
  233. alert: {
  234. show: true,
  235. clear: () => {
  236. this.selectedRowKeys = []
  237. }
  238. },
  239. rowSelection: {
  240. selectedRowKeys: this.selectedRowKeys,
  241. onChange: this.onSelectChange,
  242. getCheckboxProps: record => ({
  243. props: {
  244. disabled: false,
  245. name: record.id
  246. }
  247. })
  248. }
  249. }
  250. this.optionAlertShow = true
  251. } else {
  252. this.options = {
  253. alert: false,
  254. rowSelection: null
  255. }
  256. this.optionAlertShow = false
  257. }
  258. },
  259. batchDelete (id) {
  260. let ids = []
  261. if (this.BaseTool.String.isBlank(id)) {
  262. const length = this.selectedRows.length
  263. if (length === 0) {
  264. this.$message.info('请选择要删除的记录')
  265. return
  266. }
  267. ids = this.selectedRows.map(item => item.id)
  268. } else {
  269. ids = [id]
  270. }
  271. deleteCheckStandards(ids).then(res => {
  272. this.$message.info('删除成功')
  273. this.handleOk()
  274. this.$refs.table.clearSelected()
  275. })
  276. },
  277. handleEdit (record) {
  278. fetchCheckStandard({ id: record.id }).then(res => {
  279. const modal = this.$refs.baseModal
  280. modal.base(res.data)
  281. })
  282. },
  283. handleView (record) {
  284. fetchCheckStandard({ id: record.id }).then(res => {
  285. const modal = this.$refs.detailModal
  286. modal.base(res.data)
  287. })
  288. },
  289. /* handleCopy (record) {
  290. const modal = this.$refs.baseModal
  291. res.data.id = null
  292. modal.base(res.record)
  293. }, */
  294. handleOk () {
  295. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  296. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  297. this.$refs.table.refresh()
  298. },
  299. onSelectChange (selectedRowKeys, selectedRows) {
  300. this.selectedRowKeys = selectedRowKeys
  301. this.selectedRows = selectedRows
  302. },
  303. resetSearchForm () {
  304. this.queryParam = {
  305. type: this.type
  306. }
  307. this.$refs.table.refresh(true)
  308. },
  309. doExport () {
  310. const parameter = {
  311. ...this.queryParam,
  312. searchStartTime: this.queryParam.searchStartTime,
  313. searchEndTime: this.queryParam.searchEndTime
  314. }
  315. exportCheckStandard(parameter).then(file => {
  316. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  317. })
  318. }
  319. }
  320. }
  321. </script>