|
@@ -6,7 +6,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="18" class="right">
|
|
|
<el-card class="top">
|
|
|
- <el-button type="primary" size="small" @click="productAdd">{{
|
|
|
+ <el-button type="primary" size="small" @click="materialAdd">{{
|
|
|
$t("product_material.material.materialAdd")
|
|
|
}}</el-button>
|
|
|
</el-card>
|
|
@@ -39,8 +39,8 @@
|
|
|
:insideRules="dialogRules"
|
|
|
></test>
|
|
|
</el-dialog>
|
|
|
- <el-dialog title="预览" :visible.sync="viewModal" width="500px">
|
|
|
- </el-dialog>
|
|
|
+ <!-- <el-dialog title="预览" :visible.sync="viewModal" width="500px">
|
|
|
+ </el-dialog> -->
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -88,24 +88,57 @@ export default {
|
|
|
],
|
|
|
columns: [
|
|
|
{
|
|
|
- label: "物料类型",
|
|
|
- prop: "title",
|
|
|
+ label: this.$t("product_material.material.materialType"),
|
|
|
+ prop: "type",
|
|
|
+ render: (h, params) => {
|
|
|
+ const item = this.dialogForm.type.data.find(
|
|
|
+ (item) => item.keyName === params.type
|
|
|
+ );
|
|
|
+ return <div>{item.labelName}</div>;
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
- label: "物料编码",
|
|
|
- prop: "title",
|
|
|
+ label: this.$t("product_material.material.materialCode"),
|
|
|
+ prop: "code",
|
|
|
},
|
|
|
{
|
|
|
- label: "物料名称",
|
|
|
- prop: "title",
|
|
|
+ label: this.$t("product_material.material.materialName"),
|
|
|
+ prop: "name",
|
|
|
},
|
|
|
{
|
|
|
- label: "单位",
|
|
|
- prop: "title",
|
|
|
+ label: this.$t("product_material.material.materialUnit"),
|
|
|
+ prop: "unit",
|
|
|
},
|
|
|
{
|
|
|
- label: "说明",
|
|
|
- prop: "title",
|
|
|
+ label: this.$t("product_material.material.description"),
|
|
|
+ prop: "introduce",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: this.$t("operation"),
|
|
|
+ align: "center",
|
|
|
+ actions: [
|
|
|
+ {
|
|
|
+ text: this.$t("edit"),
|
|
|
+ type: "text",
|
|
|
+ style: {
|
|
|
+ color: "red",
|
|
|
+ },
|
|
|
+ fn: ({ row }) => {
|
|
|
+ this.handleEdit(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: this.$t("delete"),
|
|
|
+ type: "text",
|
|
|
+ // disabled: true,
|
|
|
+ style: {
|
|
|
+ color: "red",
|
|
|
+ },
|
|
|
+ fn: ({ row }) => {
|
|
|
+ this.handleDelete(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
],
|
|
|
dialogParams: {
|
|
@@ -122,7 +155,7 @@ export default {
|
|
|
label: this.$t("product_material.material.materialClassify"),
|
|
|
type: "cascader",
|
|
|
props: {
|
|
|
- label: "name",
|
|
|
+ label: "label",
|
|
|
value: "id",
|
|
|
},
|
|
|
width: "100%",
|
|
@@ -135,11 +168,30 @@ export default {
|
|
|
labelName: "labelName",
|
|
|
keyName: "keyName",
|
|
|
data: [
|
|
|
- { labelName: "原料", keyName: 1 },
|
|
|
- { labelName: "辅料", keyName: 2 },
|
|
|
- { labelName: "配件", keyName: 3 },
|
|
|
- { labelName: "包材", keyName: 4 },
|
|
|
- { labelName: "其他", keyName: 5 },
|
|
|
+ {
|
|
|
+ labelName: this.$t("product_material.material.rawMaterial"),
|
|
|
+ keyName: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ labelName: this.$t(
|
|
|
+ "product_material.material.subsidiaryMaterial"
|
|
|
+ ),
|
|
|
+ keyName: 2,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ labelName: this.$t("product_material.material.parts"),
|
|
|
+ keyName: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ labelName: this.$t(
|
|
|
+ "product_material.material.packagingMaterials"
|
|
|
+ ),
|
|
|
+ keyName: 4,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ labelName: this.$t("product_material.material.other"),
|
|
|
+ keyName: 5,
|
|
|
+ },
|
|
|
],
|
|
|
},
|
|
|
code: {
|
|
@@ -151,17 +203,17 @@ export default {
|
|
|
label: this.$t("product_material.material.materialName"),
|
|
|
type: "input",
|
|
|
},
|
|
|
- unit: {
|
|
|
- label: this.$t("product_material.material.materialUnit"),
|
|
|
- type: "select",
|
|
|
- span: 3,
|
|
|
- labelName: "labelName",
|
|
|
- keyName: "keyName",
|
|
|
- data: [
|
|
|
- { labelName: "半成品", keyName: 0 },
|
|
|
- { labelName: "成品", keyName: 1 },
|
|
|
- ],
|
|
|
- },
|
|
|
+ // unit: {
|
|
|
+ // label: this.$t("product_material.material.materialUnit"),
|
|
|
+ // type: "select",
|
|
|
+ // span: 3,
|
|
|
+ // labelName: "labelName",
|
|
|
+ // keyName: "keyName",
|
|
|
+ // data: [
|
|
|
+ // { labelName: "半成品", keyName: 0 },
|
|
|
+ // { labelName: "成品", keyName: 1 },
|
|
|
+ // ],
|
|
|
+ // },
|
|
|
introduce: {
|
|
|
label: this.$t("product_material.material.materialDescription"),
|
|
|
type: "input",
|
|
@@ -252,18 +304,31 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
- // this.getList();
|
|
|
+ API.materialTree({
|
|
|
+ type: "2",
|
|
|
+ name: "",
|
|
|
+ }).then(
|
|
|
+ (res) => {
|
|
|
+ this.dialogForm.classifyId.data = res.data.data;
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("materialTree: " + err);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ this.getList();
|
|
|
},
|
|
|
methods: {
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
API.materialList(this.req).then(
|
|
|
(res) => {
|
|
|
- this.tableList = res.data.data.list;
|
|
|
+ this.tableList = res.data.data;
|
|
|
this.loading = false;
|
|
|
},
|
|
|
(err) => {
|
|
|
- console.log("productList: " + err);
|
|
|
+ console.log("materialList: " + err);
|
|
|
this.loading = false;
|
|
|
}
|
|
|
);
|
|
@@ -272,20 +337,76 @@ export default {
|
|
|
this.total = res.data.data.count;
|
|
|
},
|
|
|
(err) => {
|
|
|
- console.log("productCount: " + err);
|
|
|
+ console.log("materialCount: " + err);
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
- productAdd() {
|
|
|
+ materialAdd() {
|
|
|
this.titleText = "add";
|
|
|
this.open = true;
|
|
|
},
|
|
|
+ handleEdit(row) {
|
|
|
+ this.titleText = "edit";
|
|
|
+ this.dialogParams = row;
|
|
|
+ this.open = true;
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm(this.$t("askDeleteData"), {
|
|
|
+ confirmButtonText: this.$t("submitText"),
|
|
|
+ cancelButtonText: this.$t("cancelText"),
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ API.materialDel({ id: row.id, type: "1" }).then(() => {
|
|
|
+ this.msgSuccess(this.$t("deleteSuccess"));
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
reload(row) {
|
|
|
- console.log(row);
|
|
|
this.req.pageNum = 1;
|
|
|
this.req.classifyId = row.id;
|
|
|
this.getList();
|
|
|
},
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.form.$refs["form"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.dialogForm.loadingStatus = true;
|
|
|
+ if (!this.dialogParams.id) {
|
|
|
+ API.materialAdd(this.dialogParams).then(
|
|
|
+ () => {
|
|
|
+ this.msgSuccess(this.$t("addSuccess"));
|
|
|
+ this.$refs.form.reset();
|
|
|
+ this.open = false;
|
|
|
+ this.dialogForm.loadingStatus = false;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("materialAdd: " + err);
|
|
|
+ this.dialogForm.loadingStatus = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ API.materialEdit(this.dialogParams).then(
|
|
|
+ () => {
|
|
|
+ this.msgSuccess(this.$t("editSuccess"));
|
|
|
+ this.$refs.form.reset();
|
|
|
+ this.open = false;
|
|
|
+ this.dialogForm.loadingStatus = false;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("materialEdit: " + err);
|
|
|
+ this.dialogForm.loadingStatus = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|