StoreCheckPlan.vue 9.8 KB

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