list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <a-card size="small" :bordered="false" class="productLaunchAuditList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品名称">
  9. <a-input id="productLaunchAuditList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productLaunchAuditList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="审核状态">
  19. <v-select
  20. v-model="queryParam.billStatus"
  21. ref="billStatus"
  22. id="productLaunchAuditList-billStatus"
  23. code="PAYMENT_TYPE"
  24. placeholder="请选择审核状态"
  25. allowClear></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productLaunchAuditList-refresh">查询</a-button>
  30. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productLaunchAuditList-reset">重置</a-button>
  31. </a-col>
  32. </a-row>
  33. </a-form>
  34. </div>
  35. <!-- 列表 -->
  36. <div style="margin-bottom: 15px">
  37. <a-button type="primary" id="productLaunchAudit-export" :loading="loading" @click="handleBatchAudit">批量审核</a-button>
  38. <span style="margin-left: 8px">
  39. <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
  40. </span>
  41. </div>
  42. <s-table
  43. class="sTable"
  44. ref="table"
  45. size="default"
  46. :row-selection="rowSelection"
  47. :rowKey="(record) => record.productSn"
  48. :columns="columns"
  49. :data="loadData"
  50. :showPagination="false"
  51. :scroll="{ x: 1450, 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'"
  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-card>
  71. </template>
  72. <script>
  73. import { STable, VSelect } from '@/components'
  74. import { productOnlineList, productBatchOnlineAudit, productOnlineAudit } from '@/api/product'
  75. export default {
  76. components: { STable, VSelect },
  77. data () {
  78. return {
  79. queryParam: { // 查询条件
  80. name: '', // 名称
  81. code: '', // 编码
  82. state: undefined // 状态
  83. },
  84. tableHeight: 0,
  85. disabled: false, // 查询、重置按钮是否可操作
  86. columns: [
  87. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  88. { title: '产品编码', dataIndex: 'code', width: 220, align: 'center' },
  89. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
  90. { title: '提交时间', dataIndex: 'updateDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '提交人', dataIndex: 'updatorName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  92. { title: '审核状态', dataIndex: 'stateDictValue', width: 110, align: 'center' },
  93. { title: '审核时间', dataIndex: 'onlineAuditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '审核人', dataIndex: 'onlineAuditPersonSn', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  95. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  96. ],
  97. selectedRowKeys: [], // Check here to configure the default column
  98. loading: false,
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. if (this.tableHeight == 0) {
  103. this.tableHeight = window.innerHeight - 380
  104. }
  105. return productOnlineList(Object.assign(parameter, this.queryParam)).then(res => {
  106. const data = res.data
  107. this.disabled = false
  108. return data
  109. })
  110. }
  111. }
  112. },
  113. computed: {
  114. hasSelected () {
  115. return this.selectedRowKeys.length > 0
  116. },
  117. rowSelection () {
  118. return {
  119. selectedRowKeys: this.selectedRowKeys,
  120. onChange: (selectedRowKeys, selectedRows) => {
  121. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
  122. this.onSelectChange(selectedRowKeys)
  123. },
  124. getCheckboxProps: record => ({
  125. props: {
  126. disabled: record.state != 'WAIT'
  127. }
  128. })
  129. }
  130. }
  131. },
  132. methods: {
  133. // 重置
  134. resetSearchForm () {
  135. this.queryParam.name = ''
  136. this.queryParam.code = ''
  137. this.queryParam.state = undefined
  138. this.$refs.table.refresh(true)
  139. },
  140. // 单个审核
  141. handleAudit (row) {
  142. this.$confirm({
  143. title: '提示',
  144. content: '确认要上线审核吗?',
  145. centered: true,
  146. onOk () {
  147. productOnlineAudit({ sn: row.productSn }).then(res => {
  148. if (res.status == 200) {
  149. _this.$message.success(res.message)
  150. _this.$refs.table.refresh()
  151. }
  152. })
  153. }
  154. })
  155. },
  156. // 批量审核
  157. handleBatchAudit () {
  158. const _this = this
  159. if (_this.selectedRowKeys.length < 1) {
  160. _this.$message.warning('请在列表勾选后再进行批量操作!')
  161. return
  162. }
  163. this.$confirm({
  164. title: '提示',
  165. content: '确认要批量上线审核吗?',
  166. centered: true,
  167. onOk () {
  168. _this.loading = true
  169. productBatchOnlineAudit(_this.selectedRowKeys).then(res => {
  170. _this.loading = false
  171. if (res.status == 200) {
  172. _this.$message.success(res.message)
  173. _this.$refs.table.refresh()
  174. }
  175. })
  176. },
  177. onCancel () {
  178. console.log('Cancel')
  179. }
  180. })
  181. },
  182. onSelectChange (selectedRowKeys) {
  183. console.log('selectedRowKeys changed: ', selectedRowKeys)
  184. this.selectedRowKeys = selectedRowKeys
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="less">
  190. .productLaunchAuditList-wrap{
  191. .sTable{
  192. margin-top: 20px;
  193. }
  194. }
  195. </style>