烟花爆竹实名登记前端
祖安之光
2026-01-30 5a4edca45d9d966560c276b6b158f2e65a96f72c
src/views/usermng/product.vue
@@ -136,7 +136,8 @@
        </el-table-column>
        <el-table-column label="操作" align="center" width="240" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle(scope.row)">查看</el-button>
              <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle('update',scope.row)">修改</el-button>
            <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle('editor',scope.row)">查看</el-button>
            <el-button v-if="getBtnPermission('delete')" type="text" style="color:red;"
                       @click="deleteHandle(scope.row)">删除
            </el-button>
@@ -157,7 +158,7 @@
        @current-change="handleCurrentChange"
      />
    </div>
    <el-dialog :title="dialogStatus==='create'|| dialogStatus === 'createNew'?'新增':'查看'" :visible.sync="dialogFormVisible"
    <el-dialog :title="dialogStatus==='create'|| dialogStatus === 'createNew'?'新增':dialogStatus === 'update'?'修改':'查看'" :visible.sync="dialogFormVisible"
               :modal-append-to-body="false" :close-on-click-modal="false" width="700px">
      <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"
               style="margin-left:50px;width:500px;" element-loading-text="保存中...">
@@ -178,7 +179,7 @@
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品小类:" prop="type">
        <el-form-item label="产品小类:" prop="secondaryType">
          <el-select v-model="dataForm.secondaryType" clearable placeholder="请选择" :disabled="dialogStatus==='editor'"
                     @change="selectChange">
            <el-option
@@ -240,7 +241,7 @@
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="submitHandle">确认</el-button>
        <el-button type="primary" @click="debouncedSubmit">确认</el-button>
      </div>
    </el-dialog>
    <div style="clear: both;"></div>
@@ -256,7 +257,7 @@
      deleteProduct,
      getMajorCategoryTree,
      getManufacturerTree, getPermitLevelTree, getSecondaryCategoryTree,
      productList,
      productList, updateOldProduct,
      updateProduct
  } from "../../api/product";
  import {parseError} from "../../utils/messageDialog";
@@ -337,13 +338,16 @@
      ...mapGetters([
        'userType',
        'username'
      ])
      ]),
        debouncedSubmit() {
            return this.debounce(this.submitHandle, 800);
        }
    },
    methods: {
      async selectChange(){
      async selectChange(second){
        this.$forceUpdate();
        this.dataForm.level = '';
        let res = await getPermitLevelTree(this.dataForm.secondaryType);
        let res = await getPermitLevelTree(second || this.dataForm.secondaryType);
        this.permitLevelOptions = res.data;
      },
      getProductMajorCategory(){
@@ -412,14 +416,22 @@
          parseError({error: error, vm: _this})
        })
      },
        debounce(func, wait) {
            let timeout;
            return (...args) => {
                clearTimeout(timeout);
                timeout = setTimeout(() => {
                    func.apply(this, args);
                }, wait);
            };
        },
      submitHandle:function(){
          if (this.dialogStatus === 'create') {
              this.createHandle();
          }else if (this.dialogStatus === 'createNew') {
              this.createNewHandle();
          }else {
              // this.updateHandle();
              this.dialogFormVisible = false;
              this.updateHandle();
          }
      },
      createHandle: function () {
@@ -524,6 +536,7 @@
          id: '',
          name: '',
          type: '',
        secondaryType: '',
          directionCode: '',
          manufacturer: '',
          specification: '',
@@ -557,7 +570,7 @@
            const userName = Cookies.get('userName');
            const name = Cookies.get('name');
            _this.dataForm['modifiedBy'] = name + '(' + userName + ')';
            updateProduct(_this.dataForm).then(response => {
              updateOldProduct(_this.dataForm).then(response => {
              const res = response.data
              if (res.code == 200) {
                _this.dialogFormVisible = false
@@ -575,10 +588,17 @@
          }
        })
      },
      showEditHandle: function (row) {
      showEditHandle: async function (type,row) {
        this.resetDataForm();
        this.dialogStatus = 'editor';
        this.dataFormSetValue(row);
          if(type == 'editor'){
              this.dialogStatus = 'editor';
          }else{
              this.dialogStatus = 'update';
          }
          await this.getProductSecondaryCategory(row.type)
          await this.selectChange(row.secondaryType)
          await this.dataFormSetValue(row);
        this.dialogFormVisible = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
@@ -588,6 +608,7 @@
        this.dataForm.id = row.id;
        this.dataForm.name = row.name;
        this.dataForm.type = row.type;
          this.dataForm.secondaryType = row.secondaryType;
        this.dataForm.directionCode = row.directionCode;
        this.dataForm.manufacturer = row.companyNumber;
        this.dataForm.specification = row.specification;