|
@@ -13,7 +13,7 @@
|
|
|
element-loading-spinner="el-icon-loading"
|
|
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
|
>
|
|
|
- <el-card>
|
|
|
+ <el-card style="margin-top: -20px">
|
|
|
<el-row :gutter="10">
|
|
|
<el-col :span="24">
|
|
|
<el-form
|
|
@@ -24,57 +24,28 @@
|
|
|
label-width="110px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
- <!-- <el-form-item
|
|
|
- label="登录名"
|
|
|
- prop="loginName"
|
|
|
- v-if="id === 'add' || isDetail"
|
|
|
- >
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.loginName"
|
|
|
- :disabled="isDetail"
|
|
|
- ></el-input>
|
|
|
- </el-form-item> -->
|
|
|
- <el-form-item label="仓库" prop="row">
|
|
|
- <!-- <el-input
|
|
|
- v-model="ruleForm.stock"
|
|
|
- :disabled="isDetail"
|
|
|
- ></el-input> -->
|
|
|
- <el-cascader
|
|
|
- :options="options"
|
|
|
- v-model="value"
|
|
|
- :disabled="true"
|
|
|
- placeholder="请输入仓库名称"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- style="width: 70%"
|
|
|
- ></el-cascader>
|
|
|
+ <el-form-item label="供应商名称" prop="supplier_code">
|
|
|
+ <search-supplier
|
|
|
+ :value="ruleForm.supplier_code"
|
|
|
+ :placeholder="'请选择供应商'"
|
|
|
+ @searchChange="selectSupplier"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="商品名称" prop="row">
|
|
|
- <!-- <el-input v-model="ruleForm.product_name"></el-input> -->
|
|
|
- <el-cascader
|
|
|
- :options="options"
|
|
|
- v-model="value"
|
|
|
- disabled="true"
|
|
|
- :placeholder="row.goods"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- style="width: 70%"
|
|
|
- ></el-cascader>
|
|
|
+ <el-form-item label="仓库名称" prop="stock_code">
|
|
|
+ <search-stock
|
|
|
+ :value="ruleForm.stock_code"
|
|
|
+ :isDetail="true"
|
|
|
+ :placeholder="'请选择备库仓库'"
|
|
|
+ :isRelation="true"
|
|
|
+ :companyCode="companyCode"
|
|
|
+ @searchChange="selectStock"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="商品属性" prop="row">
|
|
|
- <!-- <el-input v-model="ruleForm.product_attr"></el-input> -->
|
|
|
- <el-cascader
|
|
|
- :options="options"
|
|
|
- disabled="true"
|
|
|
- v-model="row.attribute"
|
|
|
- :placeholder="row.attribute"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- style="width: 70%"
|
|
|
- ></el-cascader>
|
|
|
+ <el-form-item label="商品名称" prop="good_name">
|
|
|
+ <el-input v-model="ruleForm.good_name"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="预警数量" prop="row">
|
|
|
- <el-input v-model="row.warnNumber" style="width: 70%"></el-input>
|
|
|
+ <el-form-item label="预警数量" prop="warn_num">
|
|
|
+ <el-input v-model="ruleForm.warn_num"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
@@ -93,193 +64,52 @@
|
|
|
<script>
|
|
|
import asyncRequest from "@/apis/service/stock/stockWarning";
|
|
|
import resToken from "@/mixins/resToken";
|
|
|
-import {
|
|
|
- isnumber,
|
|
|
- isMobile,
|
|
|
- validEmail,
|
|
|
- isAlphanumeric,
|
|
|
- isChinese,
|
|
|
- isEmoticon,
|
|
|
- validAlphabets,
|
|
|
-} from "@/utils/validate";
|
|
|
export default {
|
|
|
name: "stockWarning",
|
|
|
props: ["showModel", "row", "isDetail", "sitem"],
|
|
|
mixins: [resToken],
|
|
|
data() {
|
|
|
- const validateusername = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("账号不能为空!"));
|
|
|
- } else {
|
|
|
- if (value.length < 6 || value.length > 18) {
|
|
|
- callback(new Error("账号规则为6~18位数字与字母组合!"));
|
|
|
- } else {
|
|
|
- if (isnumber(value)) {
|
|
|
- callback(new Error("账号规则为6~18位数字与字母组合!"));
|
|
|
- } else if (validAlphabets(value)) {
|
|
|
- callback(new Error("账号规则为6~18位数字与字母组合!"));
|
|
|
- } else if (!isAlphanumeric(value)) {
|
|
|
- callback(new Error("账号规则为6~18位数字与字母组合!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const validatename = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("真实姓名不能为空!"));
|
|
|
- } else {
|
|
|
- if (value.length < 2 || value.length > 12) {
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else {
|
|
|
- if (!isChinese(value)) {
|
|
|
- console.log(9999);
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else if (isEmoticon(value)) {
|
|
|
- console.log(2345);
|
|
|
- callback(new Error("真实姓名规则为2~12位汉字!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const validatemobile = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("手机号不能为空!"));
|
|
|
- } else {
|
|
|
- if (!isMobile(value)) {
|
|
|
- callback(new Error("手机号格式不正确!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const validateEmail = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback();
|
|
|
- } else {
|
|
|
- if (!validEmail(value)) {
|
|
|
- callback(new Error("邮箱格式不正确!"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
return {
|
|
|
- goods: "",
|
|
|
+ input: "",
|
|
|
+ select: "1",
|
|
|
+ companyCode: "", //选择公司
|
|
|
loading: false,
|
|
|
- title: "添加账号",
|
|
|
showModelThis: this.showModel,
|
|
|
ruleForm: {
|
|
|
- username: "", // 账号
|
|
|
- name: "", // 真实姓名
|
|
|
- mobile: "",
|
|
|
- email: "",
|
|
|
- role_id: "",
|
|
|
- status: "1",
|
|
|
- item: [],
|
|
|
- stock: "", //仓库
|
|
|
- product_name: "", //商品名称
|
|
|
- product_attr: "", //商品属性
|
|
|
- warning_number: this.row, //预警数量
|
|
|
- isDisabled: true,
|
|
|
- options: [
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "A公司",
|
|
|
- // children: [
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "A公司仓库1",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "A公司仓库2",
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // },
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "B公司",
|
|
|
- // children: [
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "B公司仓库1",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "B公司仓库2",
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // },
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "C公司",
|
|
|
- // children: [
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "C公司仓库1",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // value: "",
|
|
|
- // label: "C公司仓库2",
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // },
|
|
|
- ],
|
|
|
+ supplier_code: [], //供应商名称
|
|
|
+ stock_code: [], //仓库名称
|
|
|
+ good_name: "", //产品名称
|
|
|
+ warn_num: "", //预警数量
|
|
|
},
|
|
|
rulesThis: this.rules,
|
|
|
rules: {
|
|
|
- name: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- validator: validatename,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- username: [
|
|
|
+ warn_num: [
|
|
|
{
|
|
|
required: true,
|
|
|
- validator: validateusername,
|
|
|
+ message: "预计数量不能为空",
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
- mobile: [
|
|
|
+ good_name: [
|
|
|
{
|
|
|
+ message: "产品名称不能为空",
|
|
|
required: true,
|
|
|
- validator: validatemobile,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
- email: [
|
|
|
- {
|
|
|
- required: false,
|
|
|
- validator: validateEmail,
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
- role_id: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: "请选择角色",
|
|
|
- trigger: "change",
|
|
|
- },
|
|
|
- ],
|
|
|
- item: [
|
|
|
+ supplier_code: [
|
|
|
{
|
|
|
type: "array",
|
|
|
required: true,
|
|
|
- message: "请选择所在部门",
|
|
|
+ message: "请选择供应商",
|
|
|
trigger: "change",
|
|
|
},
|
|
|
],
|
|
|
- status: [
|
|
|
+ stock_code: [
|
|
|
{
|
|
|
+ type: "array",
|
|
|
required: true,
|
|
|
- message: "请选择状态",
|
|
|
+ message: "请选择仓库",
|
|
|
trigger: "change",
|
|
|
},
|
|
|
],
|
|
@@ -307,41 +137,24 @@ export default {
|
|
|
async initForm() {
|
|
|
this.loading = true;
|
|
|
// await this.getRole();
|
|
|
- // if (this.id === "warningChange") {
|
|
|
- // this.title = "库存预警修改";
|
|
|
- // this.rulesThis = this.rules;
|
|
|
- // await this.resetForm();
|
|
|
- // } else {
|
|
|
- // if (this.isDetail) {
|
|
|
- // this.title = "库存详情";
|
|
|
- // this.rulesThis = {};
|
|
|
- // } else {
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // // await this.initData()
|
|
|
- // }
|
|
|
+ if (this.id === "add") {
|
|
|
+ this.title = "库存预警修改";
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ await this.resetForm();
|
|
|
+ } else {
|
|
|
+ if (this.isDetail) {
|
|
|
+ this.title = "库存详情";
|
|
|
+ this.rulesThis = {};
|
|
|
+ } else {
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ }
|
|
|
+ // await this.initData()
|
|
|
+ }
|
|
|
this.title = "库存预警修改";
|
|
|
this.rulesThis = this.rules;
|
|
|
// await this.resetForm(this.sitem);
|
|
|
this.loading = false;
|
|
|
},
|
|
|
- // async getRole() {
|
|
|
- // const model = {
|
|
|
- // status: "", // 状态
|
|
|
- // level: "", // 姓名
|
|
|
- // role_name: "",
|
|
|
- // };
|
|
|
- // const res = await asyncRequest.getRole(model);
|
|
|
- // if (res && res.code === 0 && res.data) {
|
|
|
- // this.roleList = res.data;
|
|
|
- // this.roleList.map((v1) => {
|
|
|
- // v1.id += "";
|
|
|
- // v1.status += "";
|
|
|
- // return v1;
|
|
|
- // });
|
|
|
- // }
|
|
|
- // },
|
|
|
async initData() {
|
|
|
const res = await asyncRequest.detail({ id: this.id });
|
|
|
if (res && res.code === 0 && res.data) {
|
|
@@ -353,33 +166,32 @@ export default {
|
|
|
this.$message.warning(res.message);
|
|
|
}
|
|
|
},
|
|
|
- async resetForm(sitem) {
|
|
|
+ async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
this.$refs.ruleForm.resetFields();
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
- // const { mobile, email, roleid, status, item } = sitem;
|
|
|
this.ruleForm = {
|
|
|
- // username: username || "", // 账号
|
|
|
- // name: nickname || "", // 真实姓名
|
|
|
- // mobile: mobile || "",
|
|
|
- // email: email || "",
|
|
|
- // role_id: roleid || "",
|
|
|
- // status: status || "",
|
|
|
- item: item || [],
|
|
|
+ stock_code: [],
|
|
|
+ supplier_code: [],
|
|
|
+ good_name: "", //产品名称
|
|
|
+ warn_num: "", //预警数量
|
|
|
};
|
|
|
if (this.id === "add" || this.isDetail) {
|
|
|
// this.rules.username[0].required = false;
|
|
|
+ console.log("当前是add或者 this.isDetail是true");
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
+ // if
|
|
|
async submitForm() {
|
|
|
+ console.log(this.id);
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
+ console.log(this.ruleForm);
|
|
|
// const { name, mobile, email, role_id, status } = JSON.parse(
|
|
|
// JSON.stringify(this.ruleForm)
|
|
|
// );
|
|
@@ -420,12 +232,32 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 选择仓库
|
|
|
+ selectStock(e) {
|
|
|
+ console.log(e);
|
|
|
+ if (e && e.id) {
|
|
|
+ this.ruleForm.stock_code = [e.code];
|
|
|
+ this.stockCode = e.code;
|
|
|
+ } else {
|
|
|
+ this.ruleForm.stockCode = [];
|
|
|
+ this.stockCode = "";
|
|
|
+ }
|
|
|
+ console.log(this.ruleForm);
|
|
|
+ this.$refs.ruleForm.validateField("stock_code");
|
|
|
+ },
|
|
|
+ // 选择供应商
|
|
|
+ selectSupplier(e) {
|
|
|
+ console.log(e);
|
|
|
+ console.log(this.ruleForm);
|
|
|
+ if (e && e.id) {
|
|
|
+ this.ruleForm.supplier_code = [e.code];
|
|
|
+ this.companyCode = e.code;
|
|
|
+ } else {
|
|
|
+ this.ruleForm.supplier_code = [];
|
|
|
+ this.companyCode = "";
|
|
|
+ }
|
|
|
+ this.$refs.ruleForm.validateField("supplier_code");
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
-</script>
|
|
|
-
|
|
|
- <style lang="scss" scoped>
|
|
|
-.stockWarning {
|
|
|
-}
|
|
|
-</style>
|
|
|
-
|
|
|
+</script>
|