From fd8e1acbc8bac690c020248b806fc4f06af1792e Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 26 Aug 2021 15:36:58 +0800
Subject: [PATCH] 禁止输入逻辑
---
src/views/home/index.vue | 49 ++++++---
src/store/modules/dict.js | 20 +++
src/views/home/column.js | 125 +++++++++++++-----------
src/components/Approval/Approval.vue | 18 --
src/store/getters.js | 1
src/components/attach/attach.vue | 6
src/components/cardPopup/cardPopup.vue | 54 +++++++++-
7 files changed, 172 insertions(+), 101 deletions(-)
diff --git a/src/components/Approval/Approval.vue b/src/components/Approval/Approval.vue
index 12e78fd..2b63b16 100644
--- a/src/components/Approval/Approval.vue
+++ b/src/components/Approval/Approval.vue
@@ -65,10 +65,10 @@
var d = this.data,
b = [];
for (var k in d) {
- console.log({
- label: d[k].menuName,
- value: d[k].type + "",
- });
+ // console.log({
+ // label: d[k].menuName,
+ // value: d[k].type + "",
+ // });
b.push({
label: d[k].menuName,
value: d[k].type + "",
@@ -199,16 +199,6 @@
Object.assign(params, this.query)
).then((resv) => {
this.data = this.data.concat(resv.data.data.records);
- // console.log(this.data);
- if (this.data.length == 0) {
- this.$store.commit("changecanDoIt", true);
- } else {
- if (this.data[0].type == 0 || this.data[0].type == 2) {
- this.$store.commit("changecanDoIt", false);
- } else {
- this.$store.commit("changecanDoIt", true);
- }
- }
});
});
});
diff --git a/src/components/attach/attach.vue b/src/components/attach/attach.vue
index 73d56ba..6d544bb 100644
--- a/src/components/attach/attach.vue
+++ b/src/components/attach/attach.vue
@@ -24,7 +24,7 @@
size="small"
plain
icon="el-icon-upload2"
- v-if="canDoIt"
+ v-if="opens"
@click="handleUpload"
>上 传
</el-button>
@@ -33,7 +33,7 @@
size="small"
icon="el-icon-delete"
plain
- v-if="canDoIt"
+ v-if="opens"
@click="handleDelete"
>删 除
</el-button>
@@ -90,7 +90,7 @@
import { mapGetters } from "vuex";
export default {
- props: ["type"],
+ props: ["type", "opens"],
data() {
var type = this.type;
var deptid = this.$route.query.deptId;
diff --git a/src/components/cardPopup/cardPopup.vue b/src/components/cardPopup/cardPopup.vue
index bfa423a..694a0cb 100644
--- a/src/components/cardPopup/cardPopup.vue
+++ b/src/components/cardPopup/cardPopup.vue
@@ -34,19 +34,19 @@
></avue-form>
</el-collapse-item>
<el-collapse-item title="附件上传/查询" name="2">
- <attach :type="imgType"></attach>
+ <attach :type="imgType" :opens="opens"></attach>
</el-collapse-item>
</el-collapse>
</div>
<div class="hand-next">
<el-button type="primary" @click="tip1up1">上一页</el-button>
- <el-button type="primary" @click="tip1" :disabled="!canDoIt"
+ <el-button type="primary" @click="tip1" :disabled="!opens"
>暂存</el-button
>
- <el-button type="primary" @click="up()" :disabled="!canDoIt">{{
+ <el-button type="primary" @click="up()" :disabled="!opens">{{
//canDoIt ? "提交审批" : "已成功提交"
- canDoIt ? "提交审批" : "提交审批"
+ opens ? "提交审批" : "提交审批"
}}</el-button>
<el-button type="info" @click="qx">取消</el-button>
</div>
@@ -82,10 +82,11 @@
column: [],
},
activeNames: ["1", "2"],
+ opens: true,
};
},
computed: {
- ...mapGetters(["useWhere", "canDoIt"]),
+ ...mapGetters(["useWhere", "canDoIt", "yanzhen"]),
},
watch: {
useWhere() {
@@ -96,14 +97,23 @@
this.type = this.data[k].type;
this.imgType = this.data[k].imgType;
this.htmls = this.data[k].datas.htmls;
-
this.apiName = this.data[k].datas.apiName;
this.name = this.data[k].menuName;
var d = this.data[k].datas.column;
+
+ //判断是否禁用按钮
+ for (var k in this.canDoIt) {
+ if (this.canDoIt[k].type == this.type) {
+ console.log(this.type + "-------" + this.canDoIt[k].opens);
+ this.opens = this.canDoIt[k].opens;
+ }
+ }
+ //是否禁用按钮
for (var k in d) {
- d[k]["disabled"] = !this.canDoIt;
+ d[k]["disabled"] = !this.opens;
}
this.option.column = d;
+
console.log("已选择type:" + this.useWhere + "--" + this.name);
this.convert();
}
@@ -155,6 +165,9 @@
});
});
},
+ aa(b) {
+ console.log(b);
+ },
up() {
//提交申请
var d = {};
@@ -168,6 +181,13 @@
this.data0 = d;
this.data0.ptype = this.type;
this.data0.cardid = this.$store.getters.userInfo.Id;
+
+ // if (!this.tipover(1, this.data0)) {
+ // console.log("不通过");
+ // return;
+ // }
+ // console.log(this.tipover(1, this.data0));
+ // return;
add(this.apiName[0], this.data0).then(() => {
this.qx();
this.$message({
@@ -177,7 +197,25 @@
this.$store.commit("changecanDoIt", false);
});
},
- tipover() {
+
+ tipover(a, b) {
+ if (a == 1) {
+ console.log(b);
+ var number = false,
+ reg = /^[0-9]+.?[0-9]*$/;
+ for (var k in b) {
+ if (k == "creditcode") {
+ if (reg.test(b[k])) {
+ number = true;
+ } else {
+ number = false;
+ }
+ } else {
+ continue;
+ }
+ }
+ return number;
+ }
this.forms = 1;
this.obj0 = {
// title0: "保安单位基本信息",
diff --git a/src/store/getters.js b/src/store/getters.js
index 415d99b..762feae 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -29,5 +29,6 @@
useWhere: state => state.dict.useWhere,
handle: state => state.dict.handle,
canDoIt: state => state.dict.canDoIt,
+ yanzhen: state => state.dict.yanzhen,
}
export default getters
diff --git a/src/store/modules/dict.js b/src/store/modules/dict.js
index 951c789..cf1a72a 100644
--- a/src/store/modules/dict.js
+++ b/src/store/modules/dict.js
@@ -8,7 +8,8 @@
ApprovalShow: false,
useWhere: 'close',
handle: true,
- canDoIt: true
+ canDoIt: [],
+ // yanzhen: true,
},
actions: {
FlowRoutes({ commit }) {
@@ -41,9 +42,22 @@
changehandle: (state, data) => {
state.handle = data
},
+ setcanDoIt: (state, data) => {
+ state.canDoIt = data;
+ console.log(state.canDoIt, 'state.canDoIt')
+ },
changecanDoIt: (state, data) => {
- state.canDoIt = data
- }
+ // console.log(data)
+ for (var k in state.canDoIt) {
+ if (state.canDoIt[k].type == data.ptype) {
+ state.canDoIt[k].opens = data.o;
+ // state.canDoIt[k].opens = true;
+ }
+ }
+ },
+ // changeyanzhen: (state, data) => {
+ // state.yanzhen = data
+ // },
}
};
diff --git a/src/views/home/column.js b/src/views/home/column.js
index a2eddda..07e2917 100644
--- a/src/views/home/column.js
+++ b/src/views/home/column.js
@@ -1,51 +1,19 @@
+// import store from "@/store/index";
+
+
+// var validatePass = (rule, value, callback) => {
+// var reg = /^[0-9]+.?[0-9]*$/;
+// if (!reg.test(value)) {
+// store.commit('changeyanzhen', false);
+// callback(new Error('请输入数字'));
+// } else {
+// store.commit('changeyanzhen', true);
+// callback();
+// }
+// };
+
+
var column = [
- {
- label: "",
- labelWidth: 20,
- type: "title",
- prop: "title0",
- span: 24,
- styles: {
- fontSize: "24px",
- },
- },
- {
- label: "统一社会信用代码",
- prop: "creditcode",
- labelWidth: 160,
- span: 12,
- rules: [
- {
- required: true,
- message: "请输入社会信用代码",
- trigger: "blur",
- },
- ],
- },
- {
- label: "辖区",
- prop: "jurisdiction",
- type: "tree",
- dicUrl: "/api/jurisdiction/lazy-trees",
- props: {
- label: "title",
- value: "id",
- },
- labelWidth: 160,
- span: 12,
- },
- {
- label: "企业类型",
- prop: "ptype",
- hide: true,
- display: false,
- },
- {
- label: "所属单位",
- prop: "deptid",
- hide: true,
- display: false,
- },
{
label: "企业名称",
prop: "enterprisename",
@@ -59,6 +27,46 @@
},
],
},
+ // {
+ // label: "",
+ // labelWidth: 20,
+ // type: "title",
+ // prop: "title0",
+ // span: 24,
+ // styles: {
+ // fontSize: "24px",
+ // },
+ // },
+ {
+ label: "统一社会信用代码",
+ prop: "creditcode",
+ labelWidth: 160,
+ span: 12,
+ rules: [
+ {
+ required: true,
+ message: "请输入社会信用代码",
+ trigger: "blur",
+ },
+ // {
+ // validator: validatePass, trigger: 'change'
+ // },
+ ],
+ },
+
+ // {
+ // label: "企业类型",
+ // prop: "ptype",
+ // hide: true,
+ // display: false,
+ // },
+ // {
+ // label: "所属单位",
+ // prop: "deptid",
+ // hide: true,
+ // display: false,
+ // },
+
{
label: "法定代表人",
prop: "representative",
@@ -83,6 +91,9 @@
message: "法定代表人电话",
trigger: "blur",
},
+ // {
+ // validator: validatePass, trigger: 'change'
+ // },
],
},
{
@@ -109,6 +120,9 @@
message: "联系人电话",
trigger: "blur",
},
+ // {
+ // validator: validatePass, trigger: 'change'
+ // },
],
},
{
@@ -220,17 +234,16 @@
],
},
{
- label: "所属地区",
- prop: "region",
+ label: "所属辖区",
+ prop: "jurisdiction",
+ type: "tree",
+ dicUrl: "/api/jurisdiction/lazy-trees",
+ props: {
+ label: "title",
+ value: "id",
+ },
labelWidth: 160,
span: 12,
- rules: [
- {
- required: true,
- message: "请输入所属地区",
- trigger: "blur",
- },
- ],
},
{
label: "登记机关",
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 053f03f..6fe51e3 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -92,6 +92,19 @@
this.cc();
this.onLoad(this.page);
this.dataCard = ourDatas;
+ var cando = [];
+ for (var k in ourDatas) {
+ cando.push({
+ opens: true,
+ type: ourDatas[k].type,
+ });
+ }
+ this.$store.commit("setcanDoIt", cando);
+ },
+ watch: {
+ useWhere() {
+ this.onLoad(this.page);
+ },
},
methods: {
onLoad(page, params = {}) {
@@ -105,25 +118,28 @@
this.data = this.data.concat(resk.data.data.records);
getListrev(page.currentPage, page.pageSize, params).then((resv) => {
this.data = this.data.concat(resv.data.data.records);
- console.log("已有申请数量", this.data.length);
- if (this.data.length == 0) {
- this.$store.commit("changecanDoIt", true);
- } else {
- this.$store.commit("changecanDoIt", false);
- }
+ console.log("已有申请数量:", this.data.length);
this.showCard = true;
this.data.forEach((item) => {
for (const key in this.dataCard) {
- if (this.dataCard[key].ptype == item.ptype) {
- console.log("已申请名称", this.dataCard[key].menuName);
- console.log("申请状态", this.dataCard[key].type);
- if (
- this.dataCard[key].type == 0 ||
- this.dataCard[key].type == 2
- ) {
- this.$store.commit("changecanDoIt", false);
- } else {
- this.$store.commit("changecanDoIt", true);
+ if (this.dataCard[key].type == item.ptype) {
+ // console.log("已申请名称:", item.enterprisename);
+ // console.log("已申请序号:", item.ptype);
+ // console.log("申请状态:", item.type);
+ for (var k in this.canDoIt) {
+ if (this.canDoIt[k].type == item.ptype) {
+ if (item.type == 0 || item.type == 2) {
+ this.$store.commit("changecanDoIt", {
+ o: false,
+ ptype: item.ptype,
+ });
+ } else {
+ this.$store.commit("changecanDoIt", {
+ o: false,
+ ptype: item.ptype,
+ });
+ }
+ }
}
}
}
@@ -163,7 +179,6 @@
this.$store.commit("doitApprovalShow", true);
return;
}
- this.onLoad(this.page);
this.$store.commit("changeuseWhere", val);
},
},
--
Gitblit v1.9.3