list.vue 7.9 KB

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