checkList.vue 7.55 KB
<template>
  <div class="system-container">
    <div class="container">
      <search-form
        class="searchTop border-shadow testDrive"
        :formModel="searchForm"
        :formList="checkFormList"
      >
        <span
          class="inline-b"
          slot="form-slot"
        >
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="testDriveTableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
            @click="refresh"
          >重置</el-button>
        </span>
      </search-form>

      <basic-table
        ref="testDriveForm"
        :tableParams="testDriveTableParams"
        :getListApi="getListApi"
        :searchForm="searchForm"
        :hasNum="false"
      >
        <span
          slot="status"
          slot-scope="scope"
        >
          <span
            class="dot"
            :class="scope.scope.approvalStatus ? USERSTATUS[scope.scope.approvalStatus].split(',')[1] : ''"
          ></span>
          <span class="statusText">{{ scope.scope.approvalStatus ? USERSTATUS[scope.scope.approvalStatus].split(',')[0] : '--'}}</span>
        </span>
        <span
          slot="table-button"
          slot-scope="scope"
        >
          <template v-for="(j, idx) in testDriveTableParams.tableOption.btnList">
            <!-- approvalStatus为1也就是未审核状态展示全部按钮 -->
            <template v-if="scope.scope.approvalStatus == 1">
              <el-button
                :key="idx"
                :type="j.type || 'text'"
                size="mini"
                plain
                @click="btnClick(j.pType, scope.scope)"
              >{{j.name}}</el-button>
            </template>
            <template v-if="(j.pType !== 'pass' && j.pType !== 'reject') && scope.scope.approvalStatus != 1 && scope.scope.isAdd == 2">
              <el-button
                :key="idx"
                :type="j.type || 'text'"
                size="mini"
                plain
                @click="btnClick(j.pType, scope.scope)"
              >{{j.name}}</el-button>
            </template>
            <!-- isAdd => 1: 只展示查看原围栏 2: 展示查看原围栏和修改后的围栏 -->
            <template v-if="(j.remark == 'viewOrigin') && scope.scope.approvalStatus != 1 && scope.scope.isAdd == 1">
              <el-button
                :key="idx"
                :type="j.type || 'text'"
                size="mini"
                plain
                @click="btnClick(j.pType, scope.scope)"
              >{{j.name}}</el-button>
            </template>
          </template>
        </span>
      </basic-table>
    </div>
  </div>
</template>

<script>
import { getList, updateFenceApproval } from 'services/testDrive'
export default {
  data() {
    return {
      searchForm: {
        keywords: ''
      },
      checkFormList: [
        {
          type: 'input',
          inputType: 'text',
          prop: 'keywords',
          placeholder: '特约店编码|店名称',
        },
        {
          type: 'select',
          prop: 'approvalStatus',
          placeholder: '请选择审核状态',
          options: [{
            value: '1',
            label: '未审核'
          }, {
            value: '2',
            label: '已通过'
          }, {
            value: '3',
            label: '已驳回'
          }]
        }
      ],
      testDriveTableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '围栏名称',
            prop: 'fenceName'
          }, {
            label: '围栏类型',
            prop: 'fenceType'
          }, {
            label: '所属大区',
            prop: 'area'
          }, {
            label: '所属省',
            prop: 'province'
          }, {
            label: '所属市',
            prop: 'city'
          }, {
            label: '特约店名称',
            prop: 'shopName'
          }, {
            label: '特约店编码',
            prop: 'shopCode'
          }, {
            label: '店级别',
            prop: 'shopLevel'
          }, {
            label: '审核结果',
            prop: 'approvalResult'
          }, {
            label: '审核结果备注',
            prop: 'remark'
          }
        ],
        tableOption: {
          width: 250,
          btnList: [
            {
              name: '查看原围栏',
              pType: 'view',
              remark: 'viewOrigin'
            },
            {
              name: '查看修改后围栏',
              pType: 'view',
              remark: 'viewUpdated'
            },
            {
              name: '通过',
              pType: 'pass',
              remark: ''
            },
            {
              name: '驳回',
              pType: 'reject',
              remark: ''
            }
          ]
        }
      },
      approvalParams: {
        id: '',
        status: 2,
        remark: ''
      },
      getListApi: getList,
      // 弹窗
      testDriveVisible: false,
      testDriveTitle: '',
      testDriveForm: {},
      testDriveData: [
        { label: '特约店名称:', prop: 'shopName', type: 'select', options: [{ label: '121', value: 'fdfa' }], clearable: true },
        { label: '车架号:', prop: 'vin', type: 'input', clearable: true },
        { label: '车型:', prop: 'modelId', type: 'select', options: [], clearable: true },
        { label: '配置:', prop: 'configDesc', type: 'input', clearable: true },
        { label: '车牌:', prop: 'licensePlate', type: 'input', clearable: true },
        { label: '外色:', prop: 'color', type: 'input', clearable: true },
        { label: '内色:', prop: 'innerColor', type: 'input', clearable: true },
        { label: '服役类型:', prop: 'serveType', type: 'select', options: [], clearable: true },
        { label: '设备号:', prop: 'sn', type: 'input', clearable: true }
      ],
    }
  },
  methods: {
    btnClick(pType, scope) {
      const { approvalId } = scope;
      this.approvalParams.id = approvalId;
      switch (pType) {
        case 'pass':
          this.approvalParams.status = 2;
          delete this.approvalParams.remark;
          this.updateFenceApproval();
          break
        case 'reject':
          this.approvalParams.status = 3;
          this.showRejectRemarks();
          break
        case 'view':
          let query = {
            fenceId: scope.bizId,
            readonlyStatus: true
          };
          const path = '/oEshield#/monitor/editFence';
          history.pushState(query, path, path);
          break
      }
    },
    showRejectRemarks() {
      this.$prompt('请输入驳回原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        this.approvalParams.remark = value;
        this.updateFenceApproval();
      }).catch(() => {
      });
    },
    updateFenceApproval() {
      updateFenceApproval(this.approvalParams).then(res => {
        const { code, message } = res;
        if (code == 200) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.$refs.testDriveForm.refreshTable()
        } else {
          this.$message({
            type: 'error',
            message
          });
        }
      })
    },
    refresh() {
      this.searchForm = {
        keywords: ''
      }
      this.$refs.testDriveForm.refreshTable()
    }
  },
}
</script>