src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -15,10 +15,22 @@
            <span>打印</span>
          </span> -->
          <span class="btn" style="margin-left: 15px">
            <i class="el-icon-s-tools"></i>
            <span>动作</span>
            <el-button
              plain
              size="mini"
              style="margin-left: 15px"
              @click="deleteClick"
              >删除</el-button
            >
          </span>
          <el-button v-if="showEdit" plain size="mini" style="margin-left: 15px" @click="editClick">编辑</el-button>
          <el-button
            v-if="showEdit"
            plain
            size="mini"
            style="margin-left: 15px"
            @click="editClick"
            >编辑</el-button
          >
        </div>
      </div>
      <!-- 内容 -->
@@ -37,9 +49,9 @@
            <el-row>
              <el-col :span="24">
                <div style="margin-left: 20px">类别</div>
                <el-form-item label="" prop="client_name" label-width="20px">
                <el-form-item label="" prop="name" label-width="20px">
                  <el-input
                    v-model="editConfig.infomation.client_name"
                    v-model="editConfig.infomation.name"
                    placeholder=""
                    :disabled="!showFooter"
                    style="width: 85%"
@@ -47,15 +59,24 @@
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="上级品类" prop="client_name" style="margin-left: 20px">
                <el-form-item
                  label="上级品类"
                  prop="parentId"
                  style="margin-left: 20px"
                >
                  <el-select
                    v-model="editConfig.infomation.memberId"
                    v-model="editConfig.infomation.parentId"
                    placeholder="请选择"
                    size="mini"
                    style="width: 45%"
                    :disabled="!showFooter"
                  >
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    <el-option
                      v-for="item in productCategoryList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
@@ -66,7 +87,7 @@
            <div class="purchase-view">
              <div class="left">
                <div class="second-label">物流</div>
                <el-form-item label="路线" prop="client_name" style="margin-left: 20px">
                <!-- <el-form-item label="路线" prop="client_name" style="margin-left: 20px">
                  <el-select
                    v-model="editConfig.infomation.memberId"
                    multiple
@@ -78,46 +99,70 @@
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="强制下架策略" prop="client_name" style="margin-left: 20px">
                </el-form-item> -->
                <el-form-item
                  label="强制下架策略"
                  prop="forceRemovalStrategy"
                  style="margin-left: 20px"
                >
                  <el-select
                    v-model="editConfig.infomation.memberId"
                    multiple
                    v-model="editConfig.infomation.forceRemovalStrategy"
                    placeholder="请选择"
                    size="mini"
                    style="width: 63%"
                    :disabled="!showFooter"
                  >
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    <el-option
                      v-for="item in forceRemovalStrategyList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
              <div class="right">
                <div class="second-label">库存计价</div>
                <el-form-item label="成本方法" prop="client_name" style="margin-left: 20px">
                <el-form-item
                  label="成本方法"
                  prop="costingMethod"
                  style="margin-left: 20px"
                >
                  <el-select
                    v-model="editConfig.infomation.memberId"
                    multiple
                    v-model="editConfig.infomation.costingMethod"
                    placeholder="请选择"
                    size="mini"
                    style="width: 63%"
                    :disabled="!showFooter"
                  >
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    <el-option
                      v-for="item in costingMethodList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="库存计价" prop="client_name" style="margin-left: 20px">
                <el-form-item
                  label="库存计价"
                  prop="inventoryValuation"
                  style="margin-left: 20px"
                >
                  <el-select
                    v-model="editConfig.infomation.memberId"
                    multiple
                    v-model="editConfig.infomation.inventoryValuation"
                    placeholder="请选择"
                    size="mini"
                    style="width: 63%"
                    :disabled="!showFooter"
                  >
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    <el-option
                      v-for="item in inventoryValuationList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
@@ -129,14 +174,24 @@
      <!-- 尾 -->
      <div v-if="showFooter" slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">保并提交审批</el-button> -->
        <el-button type="primary" size="small" @click="saveClick('form')">保存</el-button>
        <el-button size="small" @click="editConfig.visible = false">取消</el-button>
        <el-button type="primary" size="small" @click="saveClick('form')"
          >保存</el-button
        >
        <el-button size="small" @click="editConfig.visible = false"
          >取消</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  addProductCategory,
  updateProductCategory,
  deleteProductCategory,
} from "@/api/product/productCategory";
import { getDataByType } from "@/api/data";
export default {
  name: "AddProductCategoryDialog",
  props: {
@@ -146,10 +201,16 @@
        return {
          visible: false,
          title: "新建",
          infomation: { type: [] }
        }
      }
    }
          infomation: { type: [] },
        };
      },
    },
    productCategoryList: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  components: {},
  computed: {},
@@ -158,55 +219,111 @@
      dialogWidth: "50%",
      editConfig: this.editCommonConfig,
      rules: {
        client_name: [{ required: true, message: "请选择客户名称", trigger: "change" }],
        number: [{ required: true, message: "请输入退款单编号", trigger: "blur" }],
        refundDate: [{ required: true, message: "请选择退款日期", trigger: "change" }],
        memberId: [{ required: true, message: "请选择销售负责人", trigger: "change" }],
        sale_return_nunber: [{ required: true, message: "请选择销售退货单", trigger: "change" }]
        name: [{ required: true, message: "请输入", trigger: "change" }],
      },
      forceRemovalStrategyList: getDataByType("forceRemovalStrategy"),
      // 成本方法
      costingMethodList: getDataByType("costingMethod"),
      // 库存计价
      inventoryValuationList: getDataByType("inventoryValuation"),
      memberOptions: [],
      paymentTypeListOptions: [],
      showButton: true,
      showEdit: false, // 是否显示编辑按钮
      isDelClick: false, // 删除按钮是否可点击
      showFooter: false // 是否显示取消保存
    }
      showFooter: false, // 是否显示取消保存
    };
  },
  created() {
    this.setBottonView()
    this.setBottonView();
  },
  methods: {
    // 设置删除/打印/编辑是否显示
    setBottonView() {
      if (this.editConfig.title === "新建") {
        this.showButton = false
        this.showEdit = false
        this.showFooter = true
        this.showButton = false;
        this.showEdit = false;
        this.showFooter = true;
      } else {
        this.showEdit = true
        this.showFooter = false
        this.showEdit = true;
        this.showFooter = false;
      }
    },
    // 关闭
    handleClose() {
      this.editConfig.visible = false
      this.editConfig.visible = false;
    },
    // 刪除
    deleteClick() {
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation));
      deleteProductCategory({ id: data.id }).then((res) => {
        if (res.code === 200) {
          this.editConfig.visible = false;
          this.$message.success("刪除成功");
          this.$emit("refresh");
        }
      });
    },
    // 编辑
    editClick() {
      this.showEdit = false
      this.showButton = false
      this.showFooter = true
      this.showEdit = false;
      this.showButton = false;
      this.showFooter = true;
    },
    saveParams() {
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation));
      let params = {
        costingMethod: data.costingMethod,
        forceRemovalStrategy: data.forceRemovalStrategy,
        inventoryValuation: data.inventoryValuation,
        name: data.name,
        parentId: data.parentId,
      };
      if (data.id) {
        params.id = data.id;
      }
      return params;
    },
    // 保存
    saveClick() {},
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const params = this.saveParams();
          if (this.editConfig.title === "新建") {
            addProductCategory(params).then((res) => {
              if (res.code === 200) {
                this.editConfig.visible = false;
                this.$message.success("添加成功");
                this.$emit("refresh");
              }
            });
          } else {
            updateProductCategory(params).then((res) => {
              if (res.code === 200) {
                this.editConfig.visible = false;
                this.$message.success("编辑成功");
                this.$emit("refresh");
              }
            });
          }
        } else {
          console.log("error submit");
          return false;
        }
      });
    },
    // 删除
    delClick() {},
    // 产品
    productClick() {
      this.$router.push({ path: "/productManage/productList", query: { name: "产品" } })
    }
  }
}
      this.$router.push({
        path: "/productManage/productList",
        query: { name: "产品" },
      });
    },
  },
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->