CheckProject.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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.trim="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" style="margin-bottom: 8px;">
  21. <a-button v-if="($auth('check-spot-projects-add') || $auth('check-polling-projects-add'))" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="($auth('check-spot-projects-export') || $auth('check-polling-projects-export'))" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-projects-del') || $auth('check-polling-projects-del'))">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="default"
  37. rowKey="id"
  38. :columns="columns"
  39. :data="loadData"
  40. :alert="options.alert"
  41. :rowSelection="options.rowSelection"
  42. showPagination="auto"
  43. >
  44. <span slot="action" slot-scope="record">
  45. <template>
  46. <a @click="handleView(record)">查看</a>
  47. <a-divider type="vertical" />
  48. <a v-if="($auth('check-spot-projects-edit') || $auth('check-polling-projects-edit'))" @click="handleEdit(record)">修改</a>
  49. <a-divider type="vertical" />
  50. <a v-if="($auth('check-spot-projects-edit') || $auth('check-polling-projects-edit'))" @click="handleCopy(record)">复制</a>
  51. <a-divider type="vertical" />
  52. <a-popconfirm v-if="($auth('check-spot-projects-del') || $auth('check-polling-projects-del'))" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  53. <a>删除</a>
  54. </a-popconfirm>
  55. </template>
  56. </span>
  57. <span slot="enable" slot-scope="text">
  58. <badge
  59. :status="DictCache.COLOR.YES_NO[text]"
  60. :text="enableMap[text]" />
  61. </span>
  62. </s-table>
  63. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  64. <add-form :check-type="checkType" ref="addModal" @ok="handleOk"/>
  65. <detail ref="detailModal"/>
  66. </a-card>
  67. </template>
  68. <script>
  69. import { STable, Ellipsis } from '@/components'
  70. import BaseForm from './modules/BaseForm'
  71. import AddForm from './modules/AddForm'
  72. import Detail from './modules/Detail'
  73. import { getCheckProjectPage, deleteCheckProjects, fetchCheckProject, exportCheckProject } from '@/api/check/checkproject'
  74. export default {
  75. name: 'CheckProjectList',
  76. components: {
  77. STable,
  78. Ellipsis,
  79. BaseForm,
  80. Detail,
  81. AddForm
  82. },
  83. props: {
  84. /**
  85. * 检查类型: 1-点检 2-巡检
  86. */
  87. checkType: {
  88. type: Number,
  89. default: 1
  90. }
  91. },
  92. data () {
  93. return {
  94. // 查询参数
  95. queryParam: {
  96. type: this.checkType
  97. },
  98. enableMap: {},
  99. // 表头
  100. columns: [
  101. {
  102. title: '序号',
  103. dataIndex: 'index',
  104. customRender: (text, record, index) => {
  105. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  106. }
  107. },
  108. // {
  109. // title: '编码',
  110. // dataIndex: 'no'
  111. //},
  112. {
  113. title: '项目名称',
  114. dataIndex: 'name'
  115. },
  116. {
  117. title: '名称型号',
  118. dataIndex: 'sbNameModel'
  119. },
  120. {
  121. title: '设备型号',
  122. dataIndex: 'sbModel'
  123. },
  124. {
  125. title: '设备名称',
  126. dataIndex: 'sbName'
  127. },
  128. {
  129. title: '部位编码',
  130. dataIndex: 'partNo'
  131. },
  132. {
  133. title: '是否启用',
  134. dataIndex: 'enable',
  135. scopedSlots: { customRender: 'enable' }
  136. },
  137. {
  138. title: '负责人名称',
  139. dataIndex: 'createdUserName'
  140. },
  141. {
  142. title: '操作',
  143. key: 'action',
  144. width: '200px',
  145. align: 'center',
  146. scopedSlots: { customRender: 'action' }
  147. }
  148. ],
  149. // 下拉框map
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. parameter = {
  153. ...parameter,
  154. ...this.queryParam,
  155. dataScope: {
  156. }
  157. }
  158. return getCheckProjectPage(Object.assign(parameter, this.queryParam))
  159. .then(res => {
  160. return res.data
  161. })
  162. },
  163. selectedRowKeys: [],
  164. selectedRows: [],
  165. options: {
  166. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  167. rowSelection: {
  168. selectedRowKeys: this.selectedRowKeys,
  169. onChange: this.onSelectChange
  170. }
  171. },
  172. optionAlertShow: false
  173. }
  174. },
  175. created () {
  176. // 下拉框map
  177. this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  178. this.tableOption()
  179. },
  180. methods: {
  181. tableOption () {
  182. if (!this.optionAlertShow) {
  183. this.options = {
  184. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  185. rowSelection: {
  186. selectedRowKeys: this.selectedRowKeys,
  187. onChange: this.onSelectChange,
  188. getCheckboxProps: record => ({
  189. props: {
  190. disabled: false,
  191. name: record.id
  192. }
  193. })
  194. }
  195. }
  196. this.optionAlertShow = true
  197. } else {
  198. this.options = {
  199. alert: false,
  200. rowSelection: null
  201. }
  202. this.optionAlertShow = false
  203. }
  204. },
  205. batchDelete (id) {
  206. let ids = []
  207. if (this.BaseTool.String.isBlank(id)) {
  208. const length = this.selectedRows.length
  209. if (length === 0) {
  210. this.$message.info('请选择要删除的记录')
  211. return
  212. }
  213. ids = this.selectedRows.map(item => item.id)
  214. } else {
  215. ids = [id]
  216. }
  217. deleteCheckProjects(ids).then(res => {
  218. this.$message.info('删除成功')
  219. this.handleOk()
  220. this.$refs.table.clearSelected()
  221. })
  222. },
  223. handleEdit (record) {
  224. fetchCheckProject({ id: record.id }).then(res => {
  225. const modal = this.$refs.baseModal
  226. modal.base(res.data)
  227. })
  228. },
  229. handleCopy (record) {
  230. fetchCheckProject({ id: record.id }).then(res => {
  231. const modal = this.$refs.addModal
  232. modal.base(res.data)
  233. })
  234. },
  235. handleView (record) {
  236. fetchCheckProject({ id: record.id }).then(res => {
  237. const modal = this.$refs.detailModal
  238. modal.base(res.data)
  239. })
  240. },
  241. handleOk () {
  242. this.$refs.table.refresh()
  243. },
  244. onSelectChange (selectedRowKeys, selectedRows) {
  245. this.selectedRowKeys = selectedRowKeys
  246. this.selectedRows = selectedRows
  247. },
  248. resetSearchForm () {
  249. this.queryParam = {
  250. }
  251. this.$refs.table.refresh(true)
  252. },
  253. doExport () {
  254. const parameter = {
  255. ...this.queryParam
  256. }
  257. exportCheckProject(parameter).then(file => {
  258. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  259. })
  260. }
  261. }
  262. }
  263. </script>