diff --git a/src/views/modules/pms/opcAndBatchConfig/components/batchView.vue b/src/views/modules/pms/opcAndBatchConfig/components/batchView.vue
index 41da4cb..ad0c86f 100644
--- a/src/views/modules/pms/opcAndBatchConfig/components/batchView.vue
+++ b/src/views/modules/pms/opcAndBatchConfig/components/batchView.vue
@@ -1,6 +1,18 @@
- batch view
+
+
+
+
+
+
+
+
+
+ 保存设置
+ 初始化
+ 登录
+
@@ -12,12 +24,196 @@ export default {
components: { InputsArea },
props: {},
data() {
- return {};
+ return {
+ dataForm: {
+ ip: "",
+ upWeight: "",
+ downWeight: "",
+ user: "",
+ password: "",
+ projecthdl: "",
+ pcellhdl: "",
+ description: "",
+ },
+ descriptions: [
+ { label: "batch主服务器", value: "batch主服务器" },
+ { label: "batch备用服务器", value: "batch备用服务器" },
+ ],
+ label: {
+ ip: "IP",
+ upWeight: "混料上限",
+ downWeight: "混料下限",
+ user: "用户",
+ password: "密码",
+ projecthdl: "projecthdl",
+ pcellhdl: "pcellhdl",
+ description: "描述",
+ },
+ btnLoading: {
+ save: false,
+ init: false,
+ login: false,
+ },
+ initData: [],
+ activeIndex: 0,
+ };
+ },
+ watch: {
+ btnLoading: {
+ handler: (val) => {
+ if (val) {
+ document.body.style.cursor = "progress";
+ } else {
+ document.body.style.cursor = "unset";
+ }
+ },
+ deep: true,
+ },
+ "dataForm.description": function (val) {
+ console.log("here", val);
+ if (val === "batch备用服务器") {
+ this.loadData(0);
+ } else {
+ this.loadData(1);
+ }
+ },
+ },
+ mounted() {
+ this.loadInit();
+ },
+ methods: {
+ loadData(enabledValue) {
+ this.activeIndex = this.initData.findIndex((item) => item.enabled === enabledValue);
+ try {
+ Object.keys(this.dataForm).forEach((key) => {
+ this.$set(this.dataForm, key, this.initData[this.activeIndex][key]);
+ });
+ } catch (err) {
+ this.$message({
+ message: "出错",
+ type: "error",
+ duration: 1500,
+ });
+ }
+ },
+ loadInit() {
+ this.$http
+ .get("/pms/batchConstant/page", {
+ params: {
+ limit: 20,
+ page: 1,
+ },
+ })
+ .then(({ data: res }) => {
+ if (res.code === 0) {
+ this.initData = res.data.list;
+ this.loadData(1);
+ }
+ });
+ },
+ handleInit() {
+ this.btnLoading.init = true;
+ const url = "/pms/trans/batchInit";
+ this.$http.post(url).then(({ data: res }) => {
+ this.btnLoading.init = false;
+ if (res.code !== 0) {
+ this.$message({
+ message: res.msg,
+ type: "error",
+ duration: 1500,
+ });
+ return;
+ }
+ this.$message({
+ message: res.msg,
+ type: "success",
+ duration: 1500,
+ });
+ this.loadInit();
+ });
+ },
+ handleSave() {
+ this.btnLoading.save = true;
+ const url = "/pms/batchConstant/saveconfig";
+ this.$http
+ .post(
+ url,
+ { ...this.dataForm, id: this.initData[this.activeIndex].id }
+ // {
+ // headers: {
+ // token: "",
+ // },
+ // }
+ )
+ .then(({ data: res }) => {
+ this.btnLoading.save = false;
+ if (res.code !== 0) {
+ this.$message({
+ message: res.msg,
+ type: "error",
+ duration: 1500,
+ });
+ return;
+ }
+ this.$message({
+ message: res.msg,
+ type: "success",
+ duration: 1500,
+ });
+ this.loadInit();
+ });
+ },
+ handleLogin() {
+ this.btnLoading.login = true;
+ const url = "/pms/trans/batchLogin";
+ this.$http.post(url).then(({ data: res }) => {
+ this.btnLoading.login = false;
+ if (res.code !== 0) {
+ this.$message({
+ message: res.msg,
+ type: "error",
+ duration: 1500,
+ });
+ return;
+ }
+ this.$message({
+ message: res.data,
+ type: "success",
+ duration: 1500,
+ });
+ this.loadInit();
+ });
+ },
+ handleConnectOpc() {
+ this.btnLoading = true;
+ const url = "/opcua/addThisPlc";
+ this.$http
+ .post(
+ url,
+ { ...this.dataForm },
+ {
+ headers: {
+ token: "",
+ },
+ }
+ )
+ .then(({ data: res }) => {
+ this.btnLoading = false;
+ if (res.code !== 0) {
+ this.$message({
+ message: res.msg,
+ type: "error",
+ duration: 1500,
+ });
+ }
+ });
+ },
},
- created() {},
- mounted() {},
- methods: {},
};
-
+