CheckStandard.vue 10 KB

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