|
@@ -0,0 +1,167 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="my-title">{{ !dataForm.id ? "新增" : "修改" }}</div>
|
|
|
+ <el-form
|
|
|
+ :model="dataForm"
|
|
|
+ :rules="dataRule"
|
|
|
+ ref="dataForm"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="仓库类型名称" prop="name">
|
|
|
+ <el-input v-model="dataForm.name"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="上级名称" prop="parentId">
|
|
|
+ <el-select
|
|
|
+ v-model="dataForm.parentId"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in dataList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="备注" prop="notes">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ v-model="dataForm.notes"
|
|
|
+ placeholder="备注"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="onChose">取消</el-button>
|
|
|
+ <el-button type="primary" @click="dataFormSubmit()" v-reClick
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import EDesc from "../common/e-desc";
|
|
|
+import EDescItem from "../common/e-desc-item";
|
|
|
+export default {
|
|
|
+ name: "category-add-or-update",
|
|
|
+ components: {
|
|
|
+ EDesc,
|
|
|
+ EDescItem,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ id: 0,
|
|
|
+ dataForm: {
|
|
|
+ id: "",
|
|
|
+ },
|
|
|
+ dataList: [],
|
|
|
+ dataRule: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onChose() {
|
|
|
+ this.$emit("onChose");
|
|
|
+ },
|
|
|
+ async init(id) {
|
|
|
+ this.visible = true;
|
|
|
+ this.id = id || 0;
|
|
|
+ this.dataForm = {};
|
|
|
+ this.dataForm.id = id || 0
|
|
|
+
|
|
|
+ await this.getDataList();
|
|
|
+
|
|
|
+ if (this.id) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/biz-service/wh-category/info/${this.id}`),
|
|
|
+ method: "get",
|
|
|
+ params: this.$http.adornParams(),
|
|
|
+ }).then(({ data }) => {
|
|
|
+ if (data.code === "200") {
|
|
|
+ this.dataForm = data.data;
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表单提交
|
|
|
+ dataFormSubmit() {
|
|
|
+ this.$refs["dataForm"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(
|
|
|
+ `/biz-service/wh-category/${
|
|
|
+ !this.dataForm.id ? "save" : "update"
|
|
|
+ }`
|
|
|
+ ),
|
|
|
+ method: !this.dataForm.id ? "post" : "put",
|
|
|
+ data: this.$http.adornData(
|
|
|
+ !this.dataForm.id
|
|
|
+ ? {
|
|
|
+ name: this.dataForm.name,
|
|
|
+ parentId: this.dataForm.parentId,
|
|
|
+ notes: this.dataForm.notes,
|
|
|
+ }
|
|
|
+ : {
|
|
|
+ id: this.dataForm.id,
|
|
|
+ name: this.dataForm.name,
|
|
|
+ parentId: this.dataForm.parentId,
|
|
|
+ note: this.dataForm.note,
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ }).then(({ data }) => {
|
|
|
+ if (data && data.code === "200") {
|
|
|
+ this.$message({
|
|
|
+ message: "操作成功",
|
|
|
+ type: "success",
|
|
|
+ duration: 1500,
|
|
|
+ onClose: () => {
|
|
|
+ this.onChose();
|
|
|
+ this.$emit("refreshDataList");
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取数据列表
|
|
|
+ getDataList(name) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl("/biz-service/wh-category/list"),
|
|
|
+ method: "get",
|
|
|
+ params: this.$http.adornParams({
|
|
|
+ current: this.pageIndex,
|
|
|
+ size: 100,
|
|
|
+ materialName: name,
|
|
|
+ }),
|
|
|
+ }).then(({ data }) => {
|
|
|
+ if (data && data.code === "200") {
|
|
|
+ this.dataList = data.data.records;
|
|
|
+ } else {
|
|
|
+ this.dataList = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped></style>
|