|
@@ -22,15 +22,15 @@
|
|
|
status-icon
|
|
|
:size="'mini'"
|
|
|
:rules="rulesThis"
|
|
|
- label-width="80px"
|
|
|
+ label-width="70px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
- <el-form-item label="真实姓名" prop="name">
|
|
|
+ <el-form-item label="姓名" prop="nickname">
|
|
|
<el-input
|
|
|
- v-model="ruleForm.name"
|
|
|
- :placeholder="'真实姓名'"
|
|
|
+ v-model="ruleForm.nickname"
|
|
|
+ :placeholder="'姓名'"
|
|
|
:disabled="isDetail"
|
|
|
maxlength="100"
|
|
|
/>
|
|
@@ -57,7 +57,43 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="bottom-btn">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="供应商" prop="supplierNo">
|
|
|
+ <el-table
|
|
|
+ :data="ruleForm.supplierNo"
|
|
|
+ stripe
|
|
|
+ border
|
|
|
+ style="width: 100%"
|
|
|
+ :size="'mini'"
|
|
|
+ >
|
|
|
+ <el-table-column prop="code" label="供应商编码" width="180">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="label" label="供应商名称" min-width="180">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" width="50">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span>操作</span>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip effect="dark" content="删除" placement="top">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete tb-icon"
|
|
|
+ @click="deleteRow(scope.$index, ruleForm.supplierNo)"
|
|
|
+ ></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- <el-input
|
|
|
+ v-model="ruleForm.supplierNo"
|
|
|
+ :placeholder="'邮箱'"
|
|
|
+ maxlength="100"
|
|
|
+ :disabled="isDetail"
|
|
|
+ /> -->
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="tr">
|
|
|
<el-button
|
|
|
v-if="!isDetail"
|
|
|
type="primary"
|
|
@@ -68,6 +104,19 @@
|
|
|
<el-button @click="showModelThis = false" :size="'mini'">{{
|
|
|
isDetail ? "关 闭" : "取 消"
|
|
|
}}</el-button>
|
|
|
+ <div class="fl tl" style="width: 450px">
|
|
|
+ <span>添加供应商:</span>
|
|
|
+ <search-supplier
|
|
|
+ :size="'mini'"
|
|
|
+ style="width: 370px"
|
|
|
+ :value="supplierNo"
|
|
|
+ :disabled="false"
|
|
|
+ :placeholder="'供应商名称'"
|
|
|
+ :names="''"
|
|
|
+ :isDetail="false"
|
|
|
+ @searchChange="supplierChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
@@ -97,17 +146,18 @@ export default {
|
|
|
if (value === "") {
|
|
|
callback(new Error("真实姓名不能为空!"));
|
|
|
} else {
|
|
|
- if (value.length < 2 || value.length > 12) {
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else {
|
|
|
- if (!isChinese(value)) {
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else if (isEmoticon(value)) {
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
+ callback();
|
|
|
+ // if (value.length < 2 || value.length > 12) {
|
|
|
+ // callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
+ // } else {
|
|
|
+ // if (!isChinese(value)) {
|
|
|
+ // callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
+ // } else if (isEmoticon(value)) {
|
|
|
+ // callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
+ // } else {
|
|
|
+ // callback();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
};
|
|
|
const validatemobile = (rule, value, callback) => {
|
|
@@ -140,10 +190,12 @@ export default {
|
|
|
organizeList: [],
|
|
|
showModelThis: this.showModel,
|
|
|
coptions: [],
|
|
|
+ supplierNo: "",
|
|
|
is_mainoptions: [],
|
|
|
isIndeterminate: false,
|
|
|
ruleForm: {
|
|
|
- supplierNo: "",
|
|
|
+ id: "",
|
|
|
+ supplierNo: [],
|
|
|
nickname: "", // 真实姓名
|
|
|
mobile: "",
|
|
|
email: "",
|
|
@@ -158,7 +210,6 @@ export default {
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
-
|
|
|
mobile: [
|
|
|
{
|
|
|
required: true,
|
|
@@ -224,6 +275,23 @@ export default {
|
|
|
this.$message.warning(message);
|
|
|
}
|
|
|
},
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ rows.splice(index, 1);
|
|
|
+ },
|
|
|
+ async supplierChange(e) {
|
|
|
+ const { code, label } = e;
|
|
|
+ if (code !== "") {
|
|
|
+ const list = this.ruleForm.supplierNo;
|
|
|
+ const index = list.forEach((si) => si.code === code);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.ruleForm.supplierNo.push({ id: "", code, label });
|
|
|
+ } else {
|
|
|
+ this.$message.warning("该供应商已添加!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // this.parmValue.supplierNo = code ? [code] : [];
|
|
|
+ },
|
|
|
async resetForm(sitem) {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
@@ -232,95 +300,28 @@ export default {
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
if (sitem) {
|
|
|
const {
|
|
|
- username,
|
|
|
- nickname,
|
|
|
+ id,
|
|
|
+ supplierNo,
|
|
|
+ nickname, // 真实姓名
|
|
|
mobile,
|
|
|
email,
|
|
|
- roleid,
|
|
|
- status,
|
|
|
- depart,
|
|
|
- business,
|
|
|
- platform,
|
|
|
} = sitem;
|
|
|
- let depart_code = [];
|
|
|
- if (depart && depart.length > 0) {
|
|
|
- depart.forEach((a) => {
|
|
|
- depart_code.push(a.depart_code);
|
|
|
- });
|
|
|
- }
|
|
|
- let copyBusiness =
|
|
|
- business && business.length > 0 ? JSON.parse(JSON.stringify(business)) : [];
|
|
|
-
|
|
|
- let businessList =
|
|
|
- business && business.length > 0 ? JSON.parse(JSON.stringify(business)) : [];
|
|
|
- businessList.forEach((a, ai) => {
|
|
|
- let sindex = this.coptions.findIndex((b) => b.id == a.businessid);
|
|
|
- if (sindex === -1) {
|
|
|
- copyBusiness.splice(ai, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- let is_all = false,
|
|
|
- add = 0;
|
|
|
- // if(copyBusiness.length===)
|
|
|
-
|
|
|
- let resbusinesslist = [],
|
|
|
- is_main = "";
|
|
|
- if (copyBusiness && copyBusiness.length > 0) {
|
|
|
- copyBusiness.forEach((a) => {
|
|
|
- resbusinesslist.push(a.businessid);
|
|
|
- if (a.is_main === "1") {
|
|
|
- is_main = a.businessid;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- let copyplatform =
|
|
|
- platform && platform.length > 0 ? JSON.parse(JSON.stringify(platform)) : [];
|
|
|
- let platformList =
|
|
|
- platform && platform.length > 0 ? JSON.parse(JSON.stringify(platform)) : [];
|
|
|
- platformList.forEach((a, ai) => {
|
|
|
- let sindex = this.platformoptions.findIndex((b) => b.id == a.id);
|
|
|
- if (sindex === -1) {
|
|
|
- copyplatform.splice(ai, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- let resplatformlist = [];
|
|
|
- if (copyplatform && copyplatform.length > 0) {
|
|
|
- copyplatform.forEach((a) => {
|
|
|
- resplatformlist.push(a.id);
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
this.ruleForm = {
|
|
|
- username: username || "", // 供应商账号
|
|
|
- name: nickname || "", // 真实姓名
|
|
|
- mobile: mobile || "",
|
|
|
- email: email || "",
|
|
|
- role_id: roleid || "",
|
|
|
- status: status || "",
|
|
|
- itemid: depart_code,
|
|
|
- is_main: is_main || "",
|
|
|
- companyArr: resbusinesslist || [],
|
|
|
- platform: resplatformlist || [],
|
|
|
- is_all: resbusinesslist.length === this.coptions.length,
|
|
|
+ id,
|
|
|
+ supplierNo,
|
|
|
+ nickname, // 真实姓名
|
|
|
+ mobile,
|
|
|
+ email,
|
|
|
};
|
|
|
- this.isIndeterminate =
|
|
|
- resbusinesslist.length > 0 && resbusinesslist.length < this.coptions.length;
|
|
|
} else {
|
|
|
this.ruleForm = {
|
|
|
- username: "", // 供应商账号
|
|
|
- name: "", // 真实姓名
|
|
|
+ id: "",
|
|
|
+ supplierNo: [],
|
|
|
+ nickname: "", // 真实姓名
|
|
|
mobile: "",
|
|
|
email: "",
|
|
|
- role_id: "",
|
|
|
- is_all: "",
|
|
|
- status: "1",
|
|
|
- itemid: [],
|
|
|
- companyArr: [],
|
|
|
- is_main: "",
|
|
|
- platform: [],
|
|
|
};
|
|
|
- this.handleCheckAllChange();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -330,55 +331,26 @@ export default {
|
|
|
if (valid) {
|
|
|
if (!this.loading) {
|
|
|
this.loading = true;
|
|
|
- const {
|
|
|
- username,
|
|
|
- name,
|
|
|
- mobile,
|
|
|
- email,
|
|
|
- role_id,
|
|
|
- status,
|
|
|
- itemid,
|
|
|
- is_main,
|
|
|
- is_all,
|
|
|
- companyArr,
|
|
|
- platform,
|
|
|
- } = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- let list = [],
|
|
|
- isok = true;
|
|
|
- companyArr.forEach((e) => {
|
|
|
- let item = {
|
|
|
- businessid: e,
|
|
|
- is_main: is_main === e ? "1" : "0",
|
|
|
- };
|
|
|
- list.push(item);
|
|
|
- let findex = this.coptions.findIndex((a) => a.id === e && a.status === "0");
|
|
|
- if (findex !== -1) {
|
|
|
- isok = false;
|
|
|
- }
|
|
|
- });
|
|
|
- if (!isok) {
|
|
|
- this.$message.warning("不能选择禁用的业务企业!");
|
|
|
- this.loading = true;
|
|
|
+ let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ const { supplierNo } = model;
|
|
|
+
|
|
|
+ if (supplierNo.length === 0) {
|
|
|
+ this.$message.warning("至少关联一个供应商!");
|
|
|
+ this.loading = false;
|
|
|
return;
|
|
|
}
|
|
|
- const model = {
|
|
|
- id: this.id,
|
|
|
- username: username || "", // 供应商账号
|
|
|
- nickname: name || "", // 真实姓名
|
|
|
- mobile: mobile || "",
|
|
|
- email: email || "",
|
|
|
- role: role_id || "",
|
|
|
- status: status || "",
|
|
|
- itemid: itemid || [],
|
|
|
- is_all: is_all ? "1" : "0",
|
|
|
- platform: platform || [],
|
|
|
- companyArr: list,
|
|
|
- };
|
|
|
let res = {};
|
|
|
if (this.id === "add") {
|
|
|
delete model["id"];
|
|
|
+ let arr = [];
|
|
|
+ supplierNo.forEach((a) => {
|
|
|
+ arr.push(a.code);
|
|
|
+ });
|
|
|
+ model.supplierNo = arr;
|
|
|
+ console.log(model);
|
|
|
res = await asyncRequest.add(model);
|
|
|
} else {
|
|
|
+ console.log(model);
|
|
|
res = await asyncRequest.update(model);
|
|
|
}
|
|
|
this.loading = false;
|