123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <a-card size="small" :bordered="false" class="productLaunchAuditList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="产品名称">
- <a-input id="productLaunchAuditList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品编码">
- <a-input id="productLaunchAuditList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="审核状态">
- <v-select
- v-model="queryParam.state"
- ref="state"
- id="productLaunchAuditList-state"
- code="PRODUCT_ONOFFLINE_STATUS"
- placeholder="请选择审核状态"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productLaunchAuditList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productLaunchAuditList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 列表 -->
- <div style="margin-bottom: 10px">
- <a-button type="primary" v-if="$hasPermissions('B_productLaunchAudit_batchAudit')" id="productLaunchAudit-export" :loading="loading" @click="handleBatchAudit">批量审核</a-button>
- <span style="margin-left: 5px" v-if="$hasPermissions('B_productLaunchAudit_batchAudit')">
- <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
- </span>
- </div>
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :row-selection="rowSelection"
- :rowKey="(record) => record.productSn"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1200, y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 产品分类 -->
- <template slot="productType" slot-scope="text, record">
- <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
- <span v-else>--</span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- v-if="record.state=='WAIT_ONLINE_AUDIT' && $hasPermissions('B_productLaunchAudit_audit')"
- class="button-warning"
- @click="handleAudit(record)"
- id="productLaunchAuditList-audit-btn">审核</a-button>
- <span v-else>--</span>
- </template>
- </s-table>
- </a-spin>
- </a-card>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import { productOnlineList, productBatchOnlineAudit, productOnlineAudit } from '@/api/product'
- export default {
- components: { STable, VSelect },
- data () {
- return {
- spinning: false,
- queryParam: { // 查询条件
- name: '', // 名称
- code: '', // 编码
- state: undefined // 状态
- },
- tableHeight: 0,
- disabled: false, // 查询、重置按钮是否可操作
- columns: [
- { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
- { title: '提交时间', dataIndex: 'onlineSubmitTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '提交人', dataIndex: 'onlineSubmitPerson', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '审核状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '审核时间', dataIndex: 'onlineAuditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '审核人', dataIndex: 'onlineAuditPerson', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
- ],
- selectedRowKeys: [], // Check here to configure the default column
- loading: false,
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return productOnlineList(Object.assign(parameter, this.queryParam)).then(res => {
- const data = res.data
- this.disabled = false
- this.spinning = false
- return data
- })
- }
- }
- },
- computed: {
- hasSelected () {
- return this.selectedRowKeys.length > 0
- },
- rowSelection () {
- return this.$hasPermissions('B_productLaunchAudit_batchAudit') ? {
- selectedRowKeys: this.selectedRowKeys,
- onChange: (selectedRowKeys, selectedRows) => {
- console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
- this.onSelectChange(selectedRowKeys)
- },
- getCheckboxProps: record => ({
- props: {
- disabled: record.state != 'WAIT_ONLINE_AUDIT'
- }
- })
- } : null
- }
- },
- methods: {
- // 重置
- resetSearchForm () {
- this.queryParam.name = ''
- this.queryParam.code = ''
- this.queryParam.state = undefined
- this.$refs.table.refresh(true)
- },
- // 单个审核
- handleAudit (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要上线审核吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- productOnlineAudit({ sn: row.productSn }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 批量审核
- handleBatchAudit () {
- const _this = this
- if (_this.selectedRowKeys.length < 1) {
- _this.$message.warning('请在列表勾选后再进行批量操作!')
- return
- }
- this.$confirm({
- title: '提示',
- content: '确认要批量上线审核吗?',
- centered: true,
- onOk () {
- _this.loading = true
- _this.spinning = true
- productBatchOnlineAudit(_this.selectedRowKeys).then(res => {
- _this.loading = false
- if (res.status == 200) {
- _this.selectedRowKeys = []
- _this.selectedRows = []
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- },
- onCancel () {
- console.log('Cancel')
- }
- })
- },
- onSelectChange (selectedRowKeys) {
- console.log('selectedRowKeys changed: ', selectedRowKeys)
- this.selectedRowKeys = selectedRowKeys
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 235
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- }
- }
- </script>
|