list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div class="productLaunchAuditList-wrap">
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" id="productLaunchAuditList-form" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="5" :sm="24">
  9. <a-form-item label="产品名称">
  10. <a-input id="productLaunchAuditList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="产品编码">
  15. <a-input id="productLaunchAuditList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="提交时间">
  20. <rangeDate ref="rangeDate" id="productLaunchAuditList-rangeDate" :value="time" @change="dateChange" />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="4" :sm="24" v-if="queryParam.bizState == 'PASS'">
  24. <a-form-item label="是否新品">
  25. <v-select code="FLAG" id="productLaunchAuditList-isNew" v-model="queryParam.newProductFlag" allowClear placeholder="请选择产品是否为新品"></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  29. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productLaunchAuditList-refresh">查询</a-button>
  30. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productLaunchAuditList-reset">重置</a-button>
  31. </a-col>
  32. </a-row>
  33. </a-form>
  34. </div>
  35. </a-card>
  36. <!-- 状态 -->
  37. <div style="background-color: #fff;">
  38. <v-select
  39. id="productLaunchAuditList-bizState"
  40. v-model="queryParam.bizState"
  41. ref="state"
  42. showType="tabs"
  43. @change="resetSearchForm()"
  44. code="PRODUCT_LOG_BIZ_STATE"
  45. allowClear></v-select>
  46. </div>
  47. <a-card size="small" :bordered="false">
  48. <a-spin :spinning="spinning" tip="Loading...">
  49. <!-- 列表 -->
  50. <div v-if="$hasPermissions('B_productLaunchAudit_batchAudit')&&queryParam.bizState == 'WAIT'">
  51. <a-button type="primary" ghost id="productLaunchAudit-batchAudit" :loading="loading" @click="handleBatchAudit">批量审核</a-button>
  52. <span style="margin-left: 10px">
  53. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  54. </span>
  55. </div>
  56. <s-table
  57. class="sTable fixPagination"
  58. ref="table"
  59. :style="{ height: tableHeight+70+'px' }"
  60. size="small"
  61. :rowKey="(record) => record.productLogSn"
  62. rowKeyName="productLogSn"
  63. :row-selection="$hasPermissions('B_productLaunchAudit_batchAudit')&&queryParam.bizState == 'WAIT'?{ columnWidth: 40 }:null"
  64. @rowSelection="rowSelectionFun"
  65. :columns="columns"
  66. :data="loadData"
  67. :pageSize="30"
  68. :scroll="{ y: tableHeight }"
  69. :defaultLoadData="false"
  70. bordered>
  71. <!-- 产品分类 -->
  72. <template slot="productType" slot-scope="text, record">
  73. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  74. <span v-else>--</span>
  75. </template>
  76. <!-- 显示状态 -->
  77. <template slot="showFlag" slot-scope="text, record">
  78. <a-switch
  79. checkedChildren="显示"
  80. unCheckedChildren="隐藏"
  81. :id="'productLaunchAuditList-isEnable'+record.productLogSn"
  82. v-model="record.isEnable"
  83. @change="changeFlagHandle(record)" />
  84. </template>
  85. <!-- 操作 -->
  86. <template slot="action" slot-scope="text, record">
  87. <a-button
  88. size="small"
  89. type="link"
  90. v-if="record.bizState=='WAIT' && $hasPermissions('B_productLaunchAudit_audit')"
  91. class="button-warning"
  92. @click="handleAudit(record)"
  93. :id="'productLaunchAuditList-audit-btn'+record.productLogSn">审核</a-button>
  94. <span v-else>--</span>
  95. </template>
  96. </s-table>
  97. </a-spin>
  98. </a-card>
  99. </div>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. // 组件
  104. import rangeDate from '@/views/common/rangeDate.vue'
  105. import { STable, VSelect } from '@/components'
  106. // 接口
  107. import { productLogList, productLogAuditBatch, productLogAudit, updateShowFlag } from '@/api/product'
  108. export default {
  109. name: 'ProductLaunchAuditList',
  110. mixins: [commonMixin],
  111. components: { STable, VSelect, rangeDate },
  112. data () {
  113. return {
  114. spinning: false,
  115. time: [], // 提交时间
  116. tableHeight: 0, // 表格高度
  117. disabled: false, // 查询、重置按钮是否可操作
  118. loading: false, // 表格加载状态
  119. // 查询条件
  120. queryParam: {
  121. beginDate: '', // 提交开始时间
  122. endDate: '', // 提交结束时间
  123. name: '', // 名称
  124. code: '', // 编码
  125. bizType: 'ONLINE', // 上线
  126. bizState: 'WAIT', // 状态
  127. newProductFlag: undefined// 是否新品
  128. },
  129. // 加载数据方法 必须为 Promise 对象
  130. loadData: parameter => {
  131. this.disabled = true
  132. this.spinning = true
  133. // 获取表格数据
  134. return productLogList(Object.assign(parameter, this.queryParam)).then(res => {
  135. let data
  136. if (res.status == 200) {
  137. data = res.data
  138. // 计算表格序号
  139. const no = (data.pageNo - 1) * data.pageSize
  140. for (var i = 0; i < data.list.length; i++) {
  141. data.list[i].no = no + i + 1
  142. data.list[i].isEnable = data.list[i].showFlag + '' === '1'
  143. }
  144. this.disabled = false
  145. }
  146. this.spinning = false
  147. this.setTableH()// 计算表格高度
  148. return data
  149. })
  150. },
  151. rowSelectionInfo: null// 选中列表数据
  152. }
  153. },
  154. computed: {
  155. columns () {
  156. const arr = [
  157. { title: '产品名称', dataIndex: 'name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  158. { title: '产品编码', dataIndex: 'code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  159. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '15%', align: 'left' },
  160. { title: '提交时间', dataIndex: 'submitTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '提交人', dataIndex: 'submitPerson', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  162. { title: '审核状态', dataIndex: 'bizStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  163. ]
  164. if (this.queryParam.bizState == 'WAIT') {
  165. arr.splice(6, 1, { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' })
  166. } else if (this.queryParam.bizState != 'WAIT') {
  167. arr.splice(6, 1, { title: '审核时间', dataIndex: 'auditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  168. arr.splice(7, 1, { title: '审核人', dataIndex: 'auditPerson', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  169. if (this.queryParam.bizState === 'PASS') {
  170. arr.splice(8, 1, { title: '显示状态', scopedSlots: { customRender: 'showFlag' }, width: '10%', align: 'center' })
  171. }
  172. }
  173. return arr
  174. }
  175. },
  176. methods: {
  177. // 提交时间 change
  178. dateChange (date) {
  179. this.queryParam.beginDate = date[0]
  180. this.queryParam.endDate = date[1]
  181. },
  182. // 表格选中项
  183. rowSelectionFun (obj) {
  184. this.rowSelectionInfo = obj || null
  185. },
  186. // 重置
  187. resetSearchForm () {
  188. this.queryParam.name = ''
  189. this.queryParam.code = ''
  190. this.queryParam.beginDate = ''
  191. this.queryParam.endDate = ''
  192. this.queryParam.newProductFlag = undefined
  193. this.time = []
  194. this.$refs.rangeDate.resetDate(this.time)
  195. this.$refs.table.refresh(true)
  196. },
  197. // 单个审核
  198. handleAudit (row) {
  199. const _this = this
  200. const modal = this.$confirm({
  201. title: '提示',
  202. content: '请点击下方按钮确认操作',
  203. cancelText: '不通过',
  204. okText: '通过',
  205. centered: true,
  206. closable: true,
  207. onOk () {
  208. _this.singAudit(row, 'PASS')
  209. },
  210. onCancel (e) {
  211. if (!e.triggerCancel) {
  212. _this.singAudit(row, 'REFUSE')
  213. modal.destroy()
  214. }
  215. }
  216. })
  217. },
  218. // 单个审核 审核通过 审核不通过
  219. singAudit (row, state) {
  220. const _this = this
  221. _this.spinning = true
  222. productLogAudit({ productLogSn: row.productLogSn, 'bizState': state }).then(res => {
  223. if (res.status == 200) {
  224. _this.$message.success(res.message)
  225. _this.$refs.table.refresh()
  226. _this.spinning = false
  227. } else {
  228. _this.spinning = false
  229. }
  230. })
  231. },
  232. // 批量审核
  233. batchAudit (state) {
  234. const _this = this
  235. _this.loading = true
  236. _this.spinning = true
  237. const params = {
  238. productLogSnList: _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys || [],
  239. bizState: state
  240. }
  241. productLogAuditBatch(params).then(res => {
  242. _this.loading = false
  243. if (res.status == 200) {
  244. _this.$refs.table.clearSelected() // 清空表格选中项
  245. _this.$message.success(res.message)
  246. _this.$refs.table.refresh()
  247. _this.spinning = false
  248. } else {
  249. _this.spinning = false
  250. }
  251. })
  252. },
  253. // 批量审核 先判断是否有勾选数据再审核
  254. handleBatchAudit () {
  255. const _this = this
  256. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  257. _this.$message.warning('请在列表勾选后再进行批量操作!')
  258. return
  259. }
  260. const modal = this.$confirm({
  261. title: '提示',
  262. content: '请点击下方按钮确认操作',
  263. cancelText: '不通过',
  264. okText: '通过',
  265. centered: true,
  266. closable: true,
  267. onOk () {
  268. _this.batchAudit('PASS')
  269. },
  270. onCancel (e) {
  271. if (!e.triggerCancel) {
  272. _this.batchAudit('REFUSE')
  273. modal.destroy()
  274. }
  275. }
  276. })
  277. },
  278. // 修改显示状态
  279. changeFlagHandle (record) {
  280. const _data = {
  281. productLogSn: record.productLogSn,
  282. showFlag: record.isEnable ? '1' : '0'
  283. }
  284. this.spinning = true
  285. updateShowFlag(_data).then(res => {
  286. if (res.status == 200) {
  287. this.$message.success(res.message)
  288. }
  289. this.$refs.table.refresh()
  290. this.spinning = false
  291. })
  292. },
  293. // 初始化
  294. pageInit () {
  295. const _this = this
  296. this.$nextTick(() => { // 页面渲染完成后的回调
  297. _this.setTableH()
  298. })
  299. this.rowSelectionInfo = null
  300. this.$refs.table.clearTable()
  301. },
  302. // 计算表格高度
  303. setTableH () {
  304. const tableSearchH = this.$refs.tableSearch.offsetHeight
  305. this.tableHeight = window.innerHeight - tableSearchH - (this.queryParam.bizState == 'WAIT' ? 280 : 250)
  306. }
  307. },
  308. watch: {
  309. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  310. this.setTableH()
  311. }
  312. },
  313. mounted () {
  314. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  315. this.pageInit()
  316. this.resetSearchForm()
  317. }
  318. },
  319. activated () {
  320. // 如果是新页签打开,则重置当前页面
  321. if (this.$store.state.app.isNewTab) {
  322. this.pageInit()
  323. this.resetSearchForm()
  324. }
  325. // 仅刷新列表,不重置页面
  326. if (this.$store.state.app.updateList) {
  327. this.pageInit()
  328. this.$refs.table.refresh()
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="less">
  334. .productLaunchAuditList-wrap{
  335. .sTable{
  336. margin-top:10px;
  337. }
  338. .ant-tabs-bar{
  339. margin: 0;
  340. }
  341. }
  342. </style>