MeasureLog.vue 8.7 KB

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