|
@@ -1,11 +1,11 @@
|
|
|
<template>
|
|
|
<el-form
|
|
|
+ ref="ruleForm"
|
|
|
v-loading="loading"
|
|
|
:model="ruleForm"
|
|
|
:rules="rules"
|
|
|
:size="'mini'"
|
|
|
status-icon
|
|
|
- ref="ruleForm"
|
|
|
label-width="95px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
@@ -13,9 +13,9 @@
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="发货总数" prop="send_num" required>
|
|
|
<el-input
|
|
|
+ v-model="ruleForm.send_num"
|
|
|
disabled
|
|
|
placeholder="发货总数"
|
|
|
- v-model="ruleForm.send_num"
|
|
|
maxlength="100"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -39,10 +39,10 @@
|
|
|
<el-col :span="16">
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
<el-input
|
|
|
+ v-model="ruleForm.remark"
|
|
|
type="textarea"
|
|
|
placeholder="备注"
|
|
|
:autosize="{ minRows: 4, maxRows: 4 }"
|
|
|
- v-model="ruleForm.remark"
|
|
|
maxlength="100"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -59,22 +59,21 @@
|
|
|
:order_source="order_source"
|
|
|
:is-detail="false"
|
|
|
@searchChange="handleCompany"
|
|
|
- /> </el-form-item
|
|
|
- ></el-col>
|
|
|
+ /> </el-form-item></el-col>
|
|
|
<el-col
|
|
|
- :span="8"
|
|
|
v-for="(domain, index) in ruleForm.post_code"
|
|
|
:key="domain.key"
|
|
|
+ :span="8"
|
|
|
>
|
|
|
<el-form-item
|
|
|
- :label="'物流单号' + (index + 1)"
|
|
|
:key="domain.key"
|
|
|
+ :label="'物流单号' + (index + 1)"
|
|
|
:prop="'post_code.' + index + '.value'"
|
|
|
:rules="const_post"
|
|
|
>
|
|
|
<el-input
|
|
|
- placeholder="物流单号"
|
|
|
v-model="domain.value"
|
|
|
+ placeholder="物流单号"
|
|
|
minlength="9"
|
|
|
maxlength="20"
|
|
|
>
|
|
@@ -82,7 +81,7 @@
|
|
|
slot="append"
|
|
|
icon="el-icon-delete"
|
|
|
@click.prevent="removeDomain(index)"
|
|
|
- ></el-button>
|
|
|
+ />
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
@@ -93,154 +92,157 @@
|
|
|
<el-button
|
|
|
type="warning"
|
|
|
:size="'mini'"
|
|
|
- @click="addDomain"
|
|
|
icon="el-icon-circle-plus-outline"
|
|
|
- >添加快递单号</el-button
|
|
|
- >
|
|
|
- <el-button type="primary" :size="'mini'" @click="submitForm" icon="el-icon-search"
|
|
|
- >保 存
|
|
|
+ @click="addDomain"
|
|
|
+ >添加快递单号</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :size="'mini'"
|
|
|
+ icon="el-icon-search"
|
|
|
+ @click="submitForm"
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import asyncRequest from "@/apis/service/sellOut/sellOutOrder";
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
-import { isnumber, isNumeric, hasSpace, isSpecialSymbol } from "@/utils/validate";
|
|
|
+import asyncRequest from '@/apis/service/sellOut/sellOutOrder'
|
|
|
+import resToken from '@/mixins/resToken'
|
|
|
+import { isnumber, isNumeric, hasSpace, isSpecialSymbol } from '@/utils/validate'
|
|
|
// import ladderPriceVue from "@/views/goodStore/goodsCost/ladderPrice.vue";
|
|
|
export default {
|
|
|
- name: "wsmInOrderAdd",
|
|
|
- props: ["id", "sitem", "newTime"],
|
|
|
+ name: 'WsmInOrderAdd',
|
|
|
mixins: [resToken],
|
|
|
+ props: ['id', 'sitem', 'newTime'],
|
|
|
data() {
|
|
|
const validate_num = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (required && value === "") {
|
|
|
- callback(new Error("不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (required && value === '') {
|
|
|
+ callback(new Error('不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validateCode = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- const l = value.length;
|
|
|
- //else if (value === "0") {//之前支持0
|
|
|
+ const { required } = rule
|
|
|
+ const l = value.length
|
|
|
+ // else if (value === "0") {//之前支持0
|
|
|
// callback();
|
|
|
// }
|
|
|
if (required) {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("物流单号不能为空!"));
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('物流单号不能为空!'))
|
|
|
} else if (l < 9 || l > 20) {
|
|
|
- callback(new Error("仅支持纯数字或字母数字组合(9~20位)!"));
|
|
|
+ callback(new Error('仅支持纯数字或字母数字组合(9~20位)!'))
|
|
|
} else if (isnumber(value)) {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
} else if (!isNumeric(value)) {
|
|
|
- console.log(!isNumeric(value));
|
|
|
- callback(new Error("仅支持纯数字或字母数字组合(9~20位)!"));
|
|
|
+ console.log(!isNumeric(value))
|
|
|
+ callback(new Error('仅支持纯数字或字母数字组合(9~20位)!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_remark = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("不能为空!"));
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('不能为空!'))
|
|
|
} else if (hasSpace(value)) {
|
|
|
- callback(new Error("不能出现回车/换行符!"));
|
|
|
+ callback(new Error('不能出现回车/换行符!'))
|
|
|
} else if (isSpecialSymbol(value)) {
|
|
|
- callback(new Error("不能使用英文特殊字符!"));
|
|
|
+ callback(new Error('不能使用英文特殊字符!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
loading: true,
|
|
|
- order_source: "",
|
|
|
+ order_source: '',
|
|
|
const_post: {
|
|
|
required: true,
|
|
|
validator: validateCode,
|
|
|
- trigger: "blur",
|
|
|
+ trigger: 'blur'
|
|
|
},
|
|
|
ruleForm: {
|
|
|
- outCode: "",
|
|
|
- send_num: "",
|
|
|
+ outCode: '',
|
|
|
+ send_num: '',
|
|
|
post_name: [],
|
|
|
post_code: [
|
|
|
{
|
|
|
- value: "",
|
|
|
- key: Date.now(),
|
|
|
- },
|
|
|
+ value: '',
|
|
|
+ key: Date.now()
|
|
|
+ }
|
|
|
],
|
|
|
- post_fee: "",
|
|
|
- remark: "",
|
|
|
+ post_fee: '',
|
|
|
+ remark: ''
|
|
|
// sendtime: "",
|
|
|
},
|
|
|
rules: {
|
|
|
post_name: {
|
|
|
- type: "array",
|
|
|
+ type: 'array',
|
|
|
required: true,
|
|
|
- trigger: "change",
|
|
|
- message: "请输入物流公司",
|
|
|
+ trigger: 'change',
|
|
|
+ message: '请输入物流公司'
|
|
|
},
|
|
|
post_code: {
|
|
|
required: true,
|
|
|
validator: validateCode,
|
|
|
- trigger: "blur",
|
|
|
+ trigger: 'blur'
|
|
|
},
|
|
|
post_fee: {
|
|
|
required: true,
|
|
|
validator: validate_num,
|
|
|
- trigger: "blur",
|
|
|
+ trigger: 'blur'
|
|
|
},
|
|
|
remark: {
|
|
|
required: true,
|
|
|
validator: validate_remark,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
- newTime: function (val) {
|
|
|
+ newTime: function(val) {
|
|
|
if (val) {
|
|
|
- this.initForm();
|
|
|
+ this.initForm()
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.initForm();
|
|
|
+ this.initForm()
|
|
|
},
|
|
|
methods: {
|
|
|
async initForm() {
|
|
|
- this.loading = true;
|
|
|
- await this.resetForm();
|
|
|
- this.loading = false;
|
|
|
+ this.loading = true
|
|
|
+ await this.resetForm()
|
|
|
+ this.loading = false
|
|
|
},
|
|
|
removeDomain(index) {
|
|
|
if (this.ruleForm.post_code.length === 1) {
|
|
|
- this.$message.warning("至少填写一个快递单号!");
|
|
|
- return;
|
|
|
+ this.$message.warning('至少填写一个快递单号!')
|
|
|
+ return
|
|
|
}
|
|
|
if (index !== -1) {
|
|
|
- this.ruleForm.post_code.splice(index, 1);
|
|
|
+ this.ruleForm.post_code.splice(index, 1)
|
|
|
}
|
|
|
},
|
|
|
addDomain() {
|
|
|
this.ruleForm.post_code.push({
|
|
|
- value: "",
|
|
|
- key: Date.now(),
|
|
|
- });
|
|
|
+ value: '',
|
|
|
+ key: Date.now()
|
|
|
+ })
|
|
|
},
|
|
|
- //初始化表单
|
|
|
+ // 初始化表单
|
|
|
async resetForm() {
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields();
|
|
|
- this.$refs.ruleForm.clearValidate();
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ this.$refs.ruleForm.clearValidate()
|
|
|
|
|
|
const {
|
|
|
outCode,
|
|
@@ -249,48 +251,48 @@ export default {
|
|
|
post_name,
|
|
|
post_fee,
|
|
|
remark,
|
|
|
- order_source,
|
|
|
- } = this.sitem;
|
|
|
- this.order_source = order_source;
|
|
|
+ order_source
|
|
|
+ } = this.sitem
|
|
|
+ this.order_source = order_source
|
|
|
this.ruleForm = {
|
|
|
- outCode: outCode || "",
|
|
|
- send_num: send_num || "",
|
|
|
+ outCode: outCode || '',
|
|
|
+ send_num: send_num || '',
|
|
|
post_name: post_name ? [post_name] : [],
|
|
|
post_code: [
|
|
|
{
|
|
|
- value: post_code || "",
|
|
|
- key: Date.now(),
|
|
|
- },
|
|
|
+ value: post_code || '',
|
|
|
+ key: Date.now()
|
|
|
+ }
|
|
|
],
|
|
|
- post_fee: post_fee || "",
|
|
|
- remark: remark || "",
|
|
|
+ post_fee: post_fee || '',
|
|
|
+ remark: remark || ''
|
|
|
// sendtime: "",
|
|
|
- };
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
// 保存更改
|
|
|
async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
if (this.loading) {
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
- this.loading = true;
|
|
|
- const { post_name, post_code } = this.ruleForm;
|
|
|
- const postName = post_name.toString();
|
|
|
- let post_list = "";
|
|
|
+ this.loading = true
|
|
|
+ const { post_name, post_code } = this.ruleForm
|
|
|
+ const postName = post_name.toString()
|
|
|
+ let post_list = ''
|
|
|
// isok = true,
|
|
|
// is_has = 0;
|
|
|
post_code.forEach((si, sii) => {
|
|
|
- post_list += `${sii === 0 ? "" : ","}${si.value}`;
|
|
|
+ post_list += `${sii === 0 ? '' : ','}${si.value}`
|
|
|
// if (si.value === "0") {//之前支持0
|
|
|
// is_has++;
|
|
|
// if (postName !== "其他") {
|
|
|
// isok = false;
|
|
|
// }
|
|
|
// }
|
|
|
- });
|
|
|
+ })
|
|
|
// if (!isok) {
|
|
|
// this.$message.warning("快递单号填零,物流公司必须选择其他!");
|
|
|
// this.loading = false;
|
|
@@ -302,44 +304,44 @@ export default {
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
- let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- model.post_name = postName;
|
|
|
- model.post_code = post_list;
|
|
|
+ const model = JSON.parse(JSON.stringify(this.ruleForm))
|
|
|
+ model.post_name = postName
|
|
|
+ model.post_code = post_list
|
|
|
|
|
|
- delete model["send_num"];
|
|
|
- delete model["page"];
|
|
|
- console.log(model);
|
|
|
+ delete model['send_num']
|
|
|
+ delete model['page']
|
|
|
+ console.log(model)
|
|
|
|
|
|
- const { code, message } = await asyncRequest.saleoutsend(model);
|
|
|
- this.loading = false;
|
|
|
+ const { code, message } = await asyncRequest.saleoutsend(model)
|
|
|
+ this.loading = false
|
|
|
if (code === 0) {
|
|
|
this.$notify.success({
|
|
|
- title: "添加成功",
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.$emit("refresh");
|
|
|
+ title: '添加成功',
|
|
|
+ message: ''
|
|
|
+ })
|
|
|
+ this.$emit('refresh')
|
|
|
} else if (code >= 100 && code <= 104) {
|
|
|
- await this.logout();
|
|
|
+ await this.logout()
|
|
|
} else {
|
|
|
- this.$message.warning(message);
|
|
|
+ this.$message.warning(message)
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
handleCompany(e) {
|
|
|
- const { code, id, label } = e;
|
|
|
- this.ruleForm.post_name = label ? [label] : [];
|
|
|
- this.$refs.ruleForm.validateField("post_name");
|
|
|
+ const { code, id, label } = e
|
|
|
+ this.ruleForm.post_name = label ? [label] : []
|
|
|
+ this.$refs.ruleForm.validateField('post_name')
|
|
|
},
|
|
|
number_change(e, key) {
|
|
|
- this.ruleForm[key] = e + "" || "0";
|
|
|
- this.$refs.ruleForm.validateField(key);
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ this.ruleForm[key] = e + '' || '0'
|
|
|
+ this.$refs.ruleForm.validateField(key)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|