FillInfo.vue 10.0 KB

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