|
@@ -1,6 +1,10 @@
|
|
|
<template>
|
|
|
<div class="change-relation-ship">
|
|
|
- <el-dialog :title="values.addShip" :visible.sync="addShipDialog">
|
|
|
+ <el-dialog
|
|
|
+ :title="values.addShip"
|
|
|
+ :before-close="closeDialog"
|
|
|
+ :visible.sync="addShipDialog"
|
|
|
+ >
|
|
|
<el-form
|
|
|
:model="ruleForm"
|
|
|
status-icon
|
|
@@ -10,17 +14,6 @@
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
<p class="mb-20 color-AAA">{{ values.codeTip }}</p>
|
|
|
- <!-- <el-form-item-->
|
|
|
- <!-- :label="values.codeTitle"-->
|
|
|
- <!-- prop="code"-->
|
|
|
- <!-- class="mb-20"-->
|
|
|
- <!-- >-->
|
|
|
- <!-- <el-input-->
|
|
|
- <!-- v-model="ruleForm.code"-->
|
|
|
- <!-- autocomplete="off"-->
|
|
|
- <!-- :placeholder="values.pleaseEnter"-->
|
|
|
- <!-- />-->
|
|
|
- <!-- </el-form-item>-->
|
|
|
<el-form-item :label="values.codeTitle" class="mb-20">
|
|
|
<el-select v-model="codeValue" placeholder="请选择">
|
|
|
<el-option
|
|
@@ -40,6 +33,7 @@
|
|
|
</p>
|
|
|
<el-form-item prop="main" :error="mainError">
|
|
|
<el-input
|
|
|
+ style="width: 220px"
|
|
|
v-model="ruleForm.main"
|
|
|
autocomplete="off"
|
|
|
:placeholder="values.pleaseEnterCode"
|
|
@@ -60,6 +54,7 @@
|
|
|
:error="fromError"
|
|
|
>
|
|
|
<el-input
|
|
|
+ style="width: 220px"
|
|
|
v-model="item.value"
|
|
|
:placeholder="values.pleaseEnterCode"
|
|
|
:disabled="disabled"
|
|
@@ -88,7 +83,7 @@
|
|
|
@click="submitForm('ruleForm')"
|
|
|
>{{ values.add }}
|
|
|
</el-button>
|
|
|
- <el-button class="fr" @click="addShipDialog = false"
|
|
|
+ <el-button class="fr" @click="closeDialog"
|
|
|
>{{ values.cancel }}
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
@@ -97,157 +92,160 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts" >
|
|
|
-// import { relAdd } from "../../../../api/relation/api";
|
|
|
-import { Component, Vue } from "vue-property-decorator";
|
|
|
+<script lang="ts">
|
|
|
+// import {relAdd} from "../../../../api/relation/api";
|
|
|
+import { Component, Prop, Vue, Watch, Emit } from "vue-property-decorator";
|
|
|
+let checkCode = (rule: any, value: any, callback: any) => {
|
|
|
+ //TODO
|
|
|
+ callback();
|
|
|
+};
|
|
|
+let checkMain = (rule: any, value: any, callback: any) => {
|
|
|
+ //TODO
|
|
|
+ callback();
|
|
|
+};
|
|
|
+let codeList = (rule: any, value: any, callback: any) => {
|
|
|
+ //TODO
|
|
|
+ callback();
|
|
|
+};
|
|
|
@Component({
|
|
|
- name: "addRelationDialog"
|
|
|
+ name: "addRelationShip",
|
|
|
+ // props:['addRelationValue','values']
|
|
|
})
|
|
|
-export default class addRelationDialog extends Vue {
|
|
|
+export default class extends Vue {
|
|
|
+ @Prop({ default: false }) addRelationValue?: boolean;
|
|
|
+ @Prop({ default: {} }) values?: any;
|
|
|
|
|
|
- props: ["values"]
|
|
|
- data() {
|
|
|
- var checkCode = (rule, value, callback) => {
|
|
|
- //TODO
|
|
|
- callback();
|
|
|
- };
|
|
|
- var checkMain = (rule, value, callback) => {
|
|
|
- //TODO
|
|
|
- callback();
|
|
|
- };
|
|
|
- var codeList = (rule, value, callback) => {
|
|
|
- //TODO
|
|
|
- console.log(value);
|
|
|
- callback();
|
|
|
- };
|
|
|
- return {
|
|
|
- mainError: "",
|
|
|
- fromError: "",
|
|
|
- addShipDialog: false,
|
|
|
- // disabled: true,
|
|
|
- optionsCode: [
|
|
|
- {
|
|
|
- value: "cadId",
|
|
|
- label: "CADID图纸编码",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "name",
|
|
|
- label: "设备名称",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "id",
|
|
|
- label: "设备ID",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "localId",
|
|
|
- label: "本地编码",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "localName",
|
|
|
- label: "本地名称",
|
|
|
- },
|
|
|
- ],
|
|
|
- codeValue: "",
|
|
|
- MainObject: `(限制条件:${localStorage.getItem("MainObject") || "无"} )`,
|
|
|
- FromObject: `(限制条件:${localStorage.getItem("FromObject") || "无"} )`,
|
|
|
- ruleForm: {
|
|
|
- main: "",
|
|
|
- codeList: [
|
|
|
- {
|
|
|
- value: "",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- rules: {
|
|
|
- code: [
|
|
|
- { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
- { validator: checkCode, trigger: "blur" },
|
|
|
- ],
|
|
|
- main: [
|
|
|
- { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
- { validator: checkMain, trigger: "blur" },
|
|
|
- ],
|
|
|
- codeList: [
|
|
|
- { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
- { validator: codeList, trigger: "blur" },
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
- },
|
|
|
- computed: {
|
|
|
- disabled() {
|
|
|
- return this.codeValue === "" ? "disabled" : false;
|
|
|
+ mainError = "";
|
|
|
+ fromError = "";
|
|
|
+ addShipDialog = false; //是否显示tooltip
|
|
|
+ optionsCode = [
|
|
|
+ {
|
|
|
+ value: "cadId",
|
|
|
+ label: "CADID图纸编码",
|
|
|
},
|
|
|
- },
|
|
|
- watch: {},
|
|
|
- methods: {
|
|
|
- addCode() {
|
|
|
- this.ruleForm.codeList.push({
|
|
|
- value: "",
|
|
|
- key: Date.now(),
|
|
|
- });
|
|
|
+ {
|
|
|
+ value: "name",
|
|
|
+ label: "设备名称",
|
|
|
},
|
|
|
- removeCode(item) {
|
|
|
- var index = this.ruleForm.codeList.indexOf(item);
|
|
|
- if (index !== -1) {
|
|
|
- this.ruleForm.codeList.splice(index, 1);
|
|
|
- }
|
|
|
+ {
|
|
|
+ value: "id",
|
|
|
+ label: "设备ID",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: "localId",
|
|
|
+ label: "本地编码",
|
|
|
},
|
|
|
- submitForm(formName) {
|
|
|
- this.$refs[formName].validate((valid) => {
|
|
|
- console.log(valid, "valid");
|
|
|
- if (valid) {
|
|
|
- let arr = [];
|
|
|
- for (let item of this.ruleForm.codeList) {
|
|
|
- if (item.value) {
|
|
|
- arr = arr.concat(item.value);
|
|
|
- }
|
|
|
+ {
|
|
|
+ value: "localName",
|
|
|
+ label: "本地名称",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ codeValue: string = "";
|
|
|
+ MainObject: string = `(限制条件:${
|
|
|
+ localStorage.getItem("MainObject") || "无"
|
|
|
+ } )`;
|
|
|
+ FromObject: string = `(限制条件:${
|
|
|
+ localStorage.getItem("FromObject") || "无"
|
|
|
+ } )`;
|
|
|
+ ruleForm: any = {
|
|
|
+ main: "",
|
|
|
+ codeList: [
|
|
|
+ {
|
|
|
+ value: "",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ rules: object = {
|
|
|
+ code: [
|
|
|
+ { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
+ { validator: checkCode, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ main: [
|
|
|
+ { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
+ { validator: checkMain, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ codeList: [
|
|
|
+ { required: true, message: "请输入对应识别编码", trigger: "blur" },
|
|
|
+ { validator: codeList, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ public get disabled() {
|
|
|
+ return this.codeValue === "" ? "disabled" : false;
|
|
|
+ }
|
|
|
+ @Watch("addRelationValue")
|
|
|
+ getRelationValue(val: any, oldVal: any) {
|
|
|
+ if (val) {
|
|
|
+ this.addShipDialog = val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // methods
|
|
|
+ addCode() {
|
|
|
+ this.ruleForm.codeList.push({
|
|
|
+ value: "",
|
|
|
+ key: Date.now(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ closeDialog() {
|
|
|
+ this.addShipDialog = false;
|
|
|
+ this.$emit("closeAddRelation");
|
|
|
+ }
|
|
|
+ removeCode(item: any) {
|
|
|
+ var index = this.ruleForm.codeList.indexOf(item);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.ruleForm.codeList.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ submitForm(formName: string) {
|
|
|
+ this.$refs[formName].validate((valid: any) => {
|
|
|
+ if (valid) {
|
|
|
+ let arr: any[] = [];
|
|
|
+ for (let item of this.ruleForm.codeList) {
|
|
|
+ if (item.value) {
|
|
|
+ arr = arr.concat(item.value);
|
|
|
}
|
|
|
- let param = {
|
|
|
- FromContent: arr,
|
|
|
- MainContent: this.ruleForm.main,
|
|
|
- RelType: localStorage.getItem("RelManualType"),
|
|
|
- Type: this.codeValue,
|
|
|
- };
|
|
|
- //清空添加value
|
|
|
- let that = this;
|
|
|
- relAdd(param).then((res) => {
|
|
|
- if (res.data.Result === "failure") {
|
|
|
- if (res.data.ErrorType == 1) {
|
|
|
- // this.mainError = res.data.Message
|
|
|
- this.$nextTick(() => {
|
|
|
- this.mainError = res.data.Message;
|
|
|
- });
|
|
|
- } else if (res.data.ErrorType == 2) {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.fromError = res.data.Message;
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.Message);
|
|
|
- }
|
|
|
- } else if (res.data.Result === "success") {
|
|
|
- this.$message.success(res.data.Message);
|
|
|
- this.$emit("update");
|
|
|
- that.addShipDialog = false;
|
|
|
- that.codeValue = "";
|
|
|
- that.ruleForm.codeList = [{ value: "" }];
|
|
|
- that.ruleForm.main = "";
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- console.log("error");
|
|
|
- return false;
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ let param = {
|
|
|
+ FromContent: arr,
|
|
|
+ MainContent: this.ruleForm.main,
|
|
|
+ RelType: localStorage.getItem("RelManualType"),
|
|
|
+ Type: this.codeValue,
|
|
|
+ };
|
|
|
+ //清空添加value
|
|
|
+ let that = this;
|
|
|
+ // relAdd(param).then(res => {
|
|
|
+ // if (res.data.Result === "failure") {
|
|
|
+ // if(res.data.ErrorType == 1) {
|
|
|
+ // // this.mainError = res.data.Message
|
|
|
+ // this.$nextTick(()=>{this.mainError = res.data.Message})
|
|
|
+ // } else if(res.data.ErrorType == 2) {
|
|
|
+ // this.$nextTick(()=>{this.fromError = res.data.Message})
|
|
|
+ // } else {
|
|
|
+ // this.$message.error(res.data.Message);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // } else if (res.data.Result === "success") {
|
|
|
+ // this.$message.success(res.data.Message);
|
|
|
+ // this.$emit('update')
|
|
|
+ // that.addShipDialog = false
|
|
|
+ // that.codeValue = ''
|
|
|
+ // that.ruleForm.codeList = [{value:''}]
|
|
|
+ // that.ruleForm.main = ''
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ } else {
|
|
|
+ console.log("error");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="less">
|
|
|
-@color-text: #aaa;
|
|
|
+<style scoped lang="scss">
|
|
|
+$color-text: #aaa;
|
|
|
.change-relation-ship {
|
|
|
- /deep/ .el-form-item__label {
|
|
|
+ ::v-deep .el-form-item__label {
|
|
|
width: auto !important;
|
|
|
}
|
|
|
|
|
@@ -264,7 +262,7 @@ export default class addRelationDialog extends Vue {
|
|
|
}
|
|
|
|
|
|
.color-AAA {
|
|
|
- color: @color-text;
|
|
|
+ color: $color-text;
|
|
|
}
|
|
|
|
|
|
.fw-bold {
|