list.vue 12 KB

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