index.vue 10.6 KB
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="模块" prop="moduleType
">
        <el-input
          v-model="queryParams.moduleType
"
          placeholder="请输入模块"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类型" prop="recordType">
        <el-input
          v-model="queryParams.recordType"
          placeholder="请输入类型"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:config:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:config:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:config:remove']"
        >删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="valueList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="仓库编码" align="center" prop="warehouseCode"  />
      <el-table-column label="模块" align="center" prop="moduleType" :formatter="moduleFormat"  />
      <el-table-column label="类型" align="center" prop="recordType" :formatter="recordFormat" />
      <el-table-column label="标识" align="center" prop="identifier" />
      <el-table-column label="值" align="center" prop="value" :show-overflow-tooltip="true" />
      <el-table-column label="描述" align="center" prop="description" :show-overflow-tooltip="true" />
      <el-table-column label="显示差异数量" align="center" prop="prompAdjustQty" width="120" />
      <el-table-column label="显示库存数量" align="center" prop="promptQuantity"  width="120" />
      
      <el-table-column label="创建时间" align="center" prop="created" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.created) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建用户" align="center" prop="createdBy"  />
      
       <el-table-column label="更新时间" align="center" prop="lastUpdated" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdated) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新用户" align="center" prop="lastUpdatedBy" :show-overflow-tooltip="true" />
      
     
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:config:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:config:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改货主对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        
            <el-form-item label="模块" prop="moduleType">
              <el-select v-model="form.moduleType" placeholder="请选择">
                <el-option
                  v-for="dict in moduleOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>            
            <el-form-item label="类型" prop="recordType">
              <el-select v-model="form.recordType" placeholder="请选择">
                <el-option
                  v-for="dict in recordOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
        
        <el-form-item label="标识" prop="name">
          <el-input v-model="form.name" placeholder="请输入标识" />
        </el-form-item>
       <el-form-item label="值" prop="value">
          <el-input v-model="form.value" placeholder="请输入值" />
        </el-form-item>






        <el-form-item label="描述" prop="description">
          <el-input v-model="form.description" placeholder="请输入描述" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listValue,addValue, getValue,updateValue,delValue} from "@/api/config/manage/configValue";

export default {
  name: "Config",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 系统参数配置表格数据
      valueList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 模块数据字典
      moduleOptions: [],
      // 类型数据字典
      recordOptions: [],
     
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: undefined,
        name: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          { required: true, message: "盘点首选项名称不能为空", trigger: ["blur","change"] }
        ],
      }
    };
  },
  created() {
    this.getList();
     this.getDicts("moduleType").then(response => {
      this.moduleOptions = response.data;
    });
    this.getDicts("recordType").then(response => {
      this.recordOptions = response.data;
    });
  },
  methods: {
    /** 查询客户列表 */
    getList() {
      this.loading = true;
      listValue(this.queryParams).then(response => {
        console.log(response)
          this.valueList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 模块字典翻译
    moduleFormat(row, column) {
      return this.selectDictLabel(this.moduleOptions, row.moduleType);
    },
    // 类型字典翻译
    recordFormat(row, column) {
      return this.selectDictLabel(this.recordOptions, row.moduleType);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        code: undefined,
        name: undefined,
        promptLocation: undefined,
        promptLpn: undefined,
        promptItem: undefined,
        prompAdjustQty: undefined,
        promptQuantity: undefined,
        enable: undefined,
       
       
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加盘点首选项";
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      console.log(selection)
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const preferenceId = row.id || this.ids
      getValue(preferenceId).then(response => {
        console.log(response)
        this.form = response.data;
        this.open = true;
        this.title = "修改盘点首选项";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateValue(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addValue(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const preferenceIds = row.id || this.ids;
      this.$confirm('是否确认删除盘点首选项编号为"' + preferenceIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delValue(preferenceIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
  
 
  }
};
</script>