list.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <a-card size="small" :bordered="false" class="productLaunchAuditList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  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="6" :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="6" :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. <v-select
  21. v-model="queryParam.state"
  22. ref="state"
  23. id="productLaunchAuditList-state"
  24. code="PRODUCT_ONOFFLINE_STATUS"
  25. placeholder="请选择审核状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productLaunchAuditList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productLaunchAuditList-reset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <!-- 列表 -->
  37. <div style="margin-bottom: 10px">
  38. <a-button type="primary" v-if="$hasPermissions('B_productLaunchAudit_batchAudit')" id="productLaunchAudit-export" :loading="loading" @click="handleBatchAudit">批量审核</a-button>
  39. <span style="margin-left: 5px" v-if="$hasPermissions('B_productLaunchAudit_batchAudit')">
  40. <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
  41. </span>
  42. </div>
  43. <s-table
  44. class="sTable fixPagination"
  45. ref="table"
  46. :style="{ height: tableHeight+84.5+'px' }"
  47. size="small"
  48. :row-selection="rowSelection"
  49. :rowKey="(record) => record.productSn"
  50. :columns="columns"
  51. :data="loadData"
  52. :scroll="{ x: 1200, y: tableHeight }"
  53. :defaultLoadData="false"
  54. bordered>
  55. <!-- 产品分类 -->
  56. <template slot="productType" slot-scope="text, record">
  57. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  58. <span v-else>--</span>
  59. </template>
  60. <!-- 操作 -->
  61. <template slot="action" slot-scope="text, record">
  62. <a-button
  63. size="small"
  64. type="link"
  65. v-if="record.state=='WAIT_ONLINE_AUDIT' && $hasPermissions('B_productLaunchAudit_audit')"
  66. class="button-warning"
  67. @click="handleAudit(record)"
  68. id="productLaunchAuditList-audit-btn">审核</a-button>
  69. <span v-else>--</span>
  70. </template>
  71. </s-table>
  72. </a-spin>
  73. </a-card>
  74. </template>
  75. <script>
  76. import { STable, VSelect } from '@/components'
  77. import { productOnlineList, productBatchOnlineAudit, productOnlineAudit } from '@/api/product'
  78. export default {
  79. components: { STable, VSelect },
  80. data () {
  81. return {
  82. spinning: false,
  83. queryParam: { // 查询条件
  84. name: '', // 名称
  85. code: '', // 编码
  86. state: undefined // 状态
  87. },
  88. tableHeight: 0,
  89. disabled: false, // 查询、重置按钮是否可操作
  90. columns: [
  91. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  92. { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
  94. { title: '提交时间', dataIndex: 'onlineSubmitTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '提交人', dataIndex: 'onlineSubmitPerson', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  96. { title: '审核状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  97. { title: '审核时间', dataIndex: 'onlineAuditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '审核人', dataIndex: 'onlineAuditPerson', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  99. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  100. ],
  101. selectedRowKeys: [], // Check here to configure the default column
  102. loading: false,
  103. // 加载数据方法 必须为 Promise 对象
  104. loadData: parameter => {
  105. this.disabled = true
  106. this.spinning = true
  107. return productOnlineList(Object.assign(parameter, this.queryParam)).then(res => {
  108. const data = res.data
  109. this.disabled = false
  110. this.spinning = false
  111. return data
  112. })
  113. }
  114. }
  115. },
  116. computed: {
  117. hasSelected () {
  118. return this.selectedRowKeys.length > 0
  119. },
  120. rowSelection () {
  121. return this.$hasPermissions('B_productLaunchAudit_batchAudit') ? {
  122. selectedRowKeys: this.selectedRowKeys,
  123. onChange: (selectedRowKeys, selectedRows) => {
  124. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
  125. this.onSelectChange(selectedRowKeys)
  126. },
  127. getCheckboxProps: record => ({
  128. props: {
  129. disabled: record.state != 'WAIT_ONLINE_AUDIT'
  130. }
  131. })
  132. } : null
  133. }
  134. },
  135. methods: {
  136. // 重置
  137. resetSearchForm () {
  138. this.queryParam.name = ''
  139. this.queryParam.code = ''
  140. this.queryParam.state = undefined
  141. this.$refs.table.refresh(true)
  142. },
  143. // 单个审核
  144. handleAudit (row) {
  145. const _this = this
  146. this.$confirm({
  147. title: '提示',
  148. content: '确认要上线审核吗?',
  149. centered: true,
  150. onOk () {
  151. _this.spinning = true
  152. productOnlineAudit({ sn: row.productSn }).then(res => {
  153. if (res.status == 200) {
  154. _this.$message.success(res.message)
  155. _this.$refs.table.refresh()
  156. _this.spinning = false
  157. } else {
  158. _this.spinning = false
  159. }
  160. })
  161. }
  162. })
  163. },
  164. // 批量审核
  165. handleBatchAudit () {
  166. const _this = this
  167. if (_this.selectedRowKeys.length < 1) {
  168. _this.$message.warning('请在列表勾选后再进行批量操作!')
  169. return
  170. }
  171. this.$confirm({
  172. title: '提示',
  173. content: '确认要批量上线审核吗?',
  174. centered: true,
  175. onOk () {
  176. _this.loading = true
  177. _this.spinning = true
  178. productBatchOnlineAudit(_this.selectedRowKeys).then(res => {
  179. _this.loading = false
  180. if (res.status == 200) {
  181. _this.selectedRowKeys = []
  182. _this.selectedRows = []
  183. _this.$message.success(res.message)
  184. _this.$refs.table.refresh()
  185. _this.spinning = false
  186. } else {
  187. _this.spinning = false
  188. }
  189. })
  190. },
  191. onCancel () {
  192. console.log('Cancel')
  193. }
  194. })
  195. },
  196. onSelectChange (selectedRowKeys) {
  197. console.log('selectedRowKeys changed: ', selectedRowKeys)
  198. this.selectedRowKeys = selectedRowKeys
  199. },
  200. pageInit () {
  201. const _this = this
  202. this.$nextTick(() => { // 页面渲染完成后的回调
  203. _this.setTableH()
  204. })
  205. },
  206. setTableH () {
  207. const tableSearchH = this.$refs.tableSearch.offsetHeight
  208. this.tableHeight = window.innerHeight - tableSearchH - 235
  209. }
  210. },
  211. mounted () {
  212. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  213. this.pageInit()
  214. this.resetSearchForm()
  215. }
  216. },
  217. activated () {
  218. // 如果是新页签打开,则重置当前页面
  219. if (this.$store.state.app.isNewTab) {
  220. this.pageInit()
  221. this.resetSearchForm()
  222. }
  223. }
  224. }
  225. </script>