Commit 17a01eb8 authored by renjintao's avatar renjintao

mesplan

parent 947ba7a1
......@@ -344,7 +344,7 @@ henq.dirCode = (code, v) => {
}
henq.makeRules = (list, api) => {
henq.makeRules = (list, apiUrl) => {
//测试数据start
list = [{ //普通输入框
......@@ -416,12 +416,45 @@ henq.makeRules = (list, api) => {
link: 0,
defaultValue: "",
control: 0,
uniqueness: 0,
uniqueness: 0,
ruleType: "email",
},
{ //唯一性api接口校验
columnDescription: "测试列5",
dbColumnName: "colums5",
dataType: "varchar",
propertyName: "colums5",
propertyType: "String",
code: "",
isNullable: false,
isKey: false,
unit: "",
length: 50,
decimalDigits: 0,
link: 0,
defaultValue: "",
control: 0,
uniqueness: 1,//表内唯一验证
ruleType: "",
}
]
apiUrl = `${resourceUrl}/mesparttaskplansimulate/get`
//测试数据end
//唯一性校验
const validateCol = (rule, value, callback) => {
if (!value) {
return callback(new Error("输入不能为空"));
}
this.$api.post(apiUrl, value).then((r) => {
if (r.result.length > 0) {
return callback(new Error("输入数据已经存在"));
} else {
callback();
}
})
};
//手机号验证
const valideTel = (rule, value, callback) => {
var re = /^1[3-9]{1}[0-9]{9}/;
......@@ -446,6 +479,14 @@ henq.makeRules = (list, api) => {
message: "必填",
trigger: "blur"
}
if(el.uniqueness!=0)
{
let objUniqueness = {
validator: validateCol,
trigger: "blur"
}
rules[el.propertyName].push(objUniqueness)
}
} else if (el.ruleType == 'email') {
objInfo = {
required: true,
......@@ -453,25 +494,15 @@ henq.makeRules = (list, api) => {
trigger: 'blur',
type: 'email'
}
}
else if(el.ruleType == 'phone')
{
} else if (el.ruleType == 'phone') {
objInfo = {
required: true,
message: "必填",
trigger: "blur"
}
let valInfoPhone = {
validator: valideTel,
required: true,
trigger: "blur"
}
rules[el.propertyName].push(valInfoPhone)
}
}
else
{//数据字典
} else { //数据字典
objInfo = {
required: true,
message: "必选",
......
<template>
<div style="width:100%;">
<template>
<div style="width:100%;">
<Form :model="orderSearchForm" :label-width="95" :rules="ruleValidate" ref="formValidate">
<Row>
<Col span="8">
<FormItem label="产品名称" style="width:100%" prop="productId">
<Select
v-model="orderSearchForm.productId"
:placeholder="placeholdeinfo"
style="width:240px;"
>
<Option
v-for="(item,index) in list"
:key="item.index"
:value="item.value"
:label="item.label"
style="display:none"
></Option>
<Tree key="mytree" :data="data1" ref="mytree" :render="renderContent"></Tree>
</Select>
</FormItem>
</Col>
<Col span="8">
<FormItem label="产品图号" style="width:100%">
<Input v-model="orderSearchForm.drawnNumber" style="width:240px" disabled />
<Input v-model="orderSearchForm.productName" style="width:240px" v-show="false" />
<Input v-model="orderSearchForm.bomId" style="width:240px" v-show="false" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="任务类型" style="width:100%" prop="taskType">
<dictionary
code="plan.order.taskType"
v-model="orderSearchForm.taskType"
style="width:240px"
></dictionary>
</FormItem>
</Col>
</Row>
<Row>
<Col span="8">
<FormItem label="数量" style="width:100%" prop="quantity">
<InputNumber :min="0" v-model="orderSearchForm.quantity" style="width:240px"></InputNumber>
</FormItem>
</Col>
<Col span="8">
<FormItem label="开始时间" style="width:100%">
<DatePicker
type="date"
placeholder="请选择日期"
style="width:240px"
@on-change="getStartDate"
v-model="orderSearchForm.demandStartDate"
></DatePicker>
</FormItem>
</Col>
<Col span="8">
<FormItem label="完成时间" style="width:100%">
<DatePicker
type="date"
placeholder="请选择日期"
style="width:240px"
@on-change="getFinishedDate"
v-model="orderSearchForm.demandFinishDate"
></DatePicker>
</FormItem>
</Col>
</Row>
<Row>
<Col span="8">
<FormItem label="项目号" style="width:100%">
<Input v-model="orderSearchForm.projectNumber" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="批次号" style="width:100%">
<Input v-model="orderSearchForm.batchNumber" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="紧急程度" style="width:100%">
<dictionary
style="width:240px"
code="plan.order.urgencyLevel"
v-model="orderSearchForm.urgencyLevel"
></dictionary>
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="任务要求" style="width:100%">
<Input v-model="orderSearchForm.taskRequire" placeholder />
</FormItem>
</Col>
<Col span="24">
<FormItem label="备注" style="width:100%">
<Input v-model="orderSearchForm.remark" placeholder type="textarea" :rows="3" />
</FormItem>
</Col>
<Col span="24">
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Col>
</Row>
<Row>
<Col span="8">
<FormItem label="产品名称" style="width:100%" prop="productId">
<Select v-model="orderSearchForm.productId" :placeholder="placeholdeinfo" style="width:240px;">
<Option v-for="(item,index) in list" :key="item.index" :value="item.value" :label="item.label" style="display:none"></Option>
<Tree key="mytree" :data="data1" ref="mytree" :render="renderContent"></Tree>
</Select>
</FormItem>
</Col>
<Col span="8">
<FormItem label="产品图号" style="width:100%">
<Input v-model="orderSearchForm.drawnNumber" style="width:240px" disabled />
<Input v-model="orderSearchForm.productName" style="width:240px" v-show="false" />
<Input v-model="orderSearchForm.bomId" style="width:240px" v-show="false" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="任务类型" style="width:100%" prop="taskType">
<dictionary code="plan.order.taskType" v-model="orderSearchForm.taskType" style="width:240px"></dictionary>
</FormItem>
</Col>
</Row>
<Row>
<Col span="8">
<FormItem label="数量" style="width:100%" prop="quantity">
<InputNumber :min="0" v-model="orderSearchForm.quantity" style="width:240px"></InputNumber>
</FormItem>
</Col>
<Col span="8">
<FormItem label="开始时间" style="width:100%">
<DatePicker type="date" placeholder="请选择日期" style="width:240px" @on-change="getStartDate" v-model="orderSearchForm.demandStartDate"></DatePicker>
</FormItem>
</Col>
<Col span="8">
<FormItem label="完成时间" style="width:100%">
<DatePicker type="date" placeholder="请选择日期" style="width:240px" @on-change="getFinishedDate" v-model="orderSearchForm.demandFinishDate"></DatePicker>
</FormItem>
</Col>
</Row>
<Row>
<Col span="8">
<FormItem label="项目号" style="width:100%">
<Input v-model="orderSearchForm.projectNumber" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="批次号" style="width:100%">
<Input v-model="orderSearchForm.batchNumber" style="width:240px" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="紧急程度" style="width:100%">
<dictionary style="width:240px" code="plan.order.urgencyLevel" v-model="orderSearchForm.urgencyLevel"></dictionary>
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="任务要求" style="width:100%">
<Input v-model="orderSearchForm.taskRequire" placeholder />
</FormItem>
</Col>
<Col span="24">
<FormItem label="备注" style="width:100%">
<Input v-model="orderSearchForm.remark" placeholder type="textarea" :rows="3" />
</FormItem>
</Col>
<Col span="24">
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Col>
</Row>
</Form>
</div>
</div>
</template>
<script>
<script>
var myDate = new Date();
var dayTomorrow = new Date();
dayTomorrow.setTime(dayTomorrow.getTime() + 24 * 60 * 60 * 1000);
var nowDate =
myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
var tomorrowDate =
dayTomorrow.getFullYear() +
"-" +
(dayTomorrow.getMonth() + 1) +
"-" +
dayTomorrow.getDate();
dayTomorrow.getFullYear() +
"-" +
(dayTomorrow.getMonth() + 1) +
"-" +
dayTomorrow.getDate();
import Api from "./api";
export default {
name: "Add",
data() {
return {
divHeight: "260px",
list: [],
data1: [],
selectdata: [],
placeholdeinfo: "请选择",
orderSearchForm: {
id: null,
productId: null, //产品id
productName: "", //产品名称
drawnNumber: null, //图号
taskType: null, //任务类型
quantity: 1, //数量
taskRequire: "", //任务接点要求
demandStartDate: this.getFormatDate(nowDate), //开始时间
demandFinishDate: this.getFormatDateEnd(tomorrowDate), //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null, //紧急程度
bomId: null,
},
ruleValidate: {
productId: [
{
required: true,
message: "请选择产品名称",
type: "number",
trigger: "change",
},
],
taskType: [
{
required: true,
message: "请选择任务类型",
trigger: "change",
type: "number",
},
],
quantity: [
{
required: true,
message: "请输入数量",
type: "number",
trigger: "change",
},
],
},
wfstatu: 1,
};
},
mounted() {
let params = {
id: "123327da-42b3-41f6-b785-cf933f137a95",
};
this.$api.get(`${workflowUrl}/schema/getbyid`, params).then((res) => {
if (res.success) {
let wfStatus = res.result.status;
if (wfStatus == 0) {
this.wfstatu = 1;
} else {
this.wfstatu = 3;
}
}
});
this.loadTree();
},
methods: {
handleSubmit() {
this.$refs.formValidate.validate((v) => {
if (v) {
this.orderSearchForm.status = this.wfstatu;
Api.mesplancreate(this.orderSearchForm)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.resetFields();
this.$emit("on-close");
},
l(key) {
key = "mes_plan" + "." + key;
return this.$t(key);
},
handleSelect(data) {
// console.log(data);
if (data.length > 0) {
this.selectdata = [];
this.selectdata = data;
this.list = [];
this.list.push({ label: data[0].title, value: data[0].id });
if (data[0].isProduct == 1) {
this.orderSearchForm.productName = data[0].title;
this.orderSearchForm.productId = data[0].productId;
this.orderSearchForm.drawnNumber = data[0].drawingNo;
this.orderSearchForm.bomId = data[0].bomId;
} else {
this.$Message.error("此节点不是产品,请选择产品节点!");
}
}
},
resetFields() {
this.orderSearchForm = {
productId: null, //产品id
productName: "", //产品名称
drawnNumber: null, //图号
taskType: null, //任务类型
quantity: 1, //数量
taskRequire: "", //任务接点要求
demandStartDate: this.getFormatDate(nowDate), //开始时间
demandFinishDate: this.getFormatDateEnd(tomorrowDate), //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null, //紧急程度
};
},
loadTree() {
//打开新增订单窗口加载产品
this.resetFields();
var sumData = [];
this.$http.order.getallselecttree().then((res) => {
if (res.result) {
for (var i = 0; i < res.result.length; i++) {
sumData = sumData.concat(res.result[i]);
}
this.data1 = sumData;
} else {
this.$Message.error("加载产品树失败!");
}
});
},
renderContent(h, { root, node, data }) {
let type = "md-folder";
let title = data.title;
if (data.isProduct != 0) {
let version = this.$store.getters.dictionaryByCode(
"material.main.version",
data.version
);
type = "ios-image";
if (version) {
title = data.title + "(" + data.mmcode + "/" + version.name + ")";
} else {
title = data.title + "(" + data.mmcode + ")";
}
}
return h(
"span",
{
on: {
click: () => {
let arrTree = [];
arrTree.push(data);
this.handleSelect(arrTree); //手动选择树节点
},
},
},
[
h("Icon", {
props: {
type: type,
},
style: {
marginRight: "8px",
name: "Add",
data() {
return {
divHeight: "260px",
list: [],
data1: [],
selectdata: [],
placeholdeinfo: "请选择",
orderSearchForm: {
id: null,
productId: null, //产品id
productName: "", //产品名称
drawnNumber: null, //图号
taskType: null, //任务类型
quantity: 1, //数量
taskRequire: "", //任务接点要求
demandStartDate: this.getFormatDate(nowDate), //开始时间
demandFinishDate: this.getFormatDateEnd(tomorrowDate), //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null, //紧急程度
bomId: null,
},
}),
h(
"span",
{
style: {
color: data.isProduct == 0 ? "#000" : "rgba(38, 128, 235, 1)",
},
ruleValidate: {
productId: [{
required: true,
message: "请选择产品名称",
type: "number",
trigger: "change",
}, ],
taskType: [{
required: true,
message: "请选择任务类型",
trigger: "change",
type: "number",
}, ],
quantity: [{
required: true,
message: "请输入数量",
type: "number",
trigger: "change",
}, ],
},
title
),
]
);
},
//时间相关start
getStartDate(value) {
if (value == "") {
this.orderSearchForm.demandStartDate = this.getFormatDate(nowDate);
} else {
this.orderSearchForm.demandStartDate = this.getFormatDate(value);
}
},
getFinishedDate(value) {
if (value == "") {
this.orderSearchForm.demandFinishDate = this.getFormatDateEnd(
tomorrowDate
);
} else {
this.orderSearchForm.demandFinishDate = this.getFormatDateEnd(value);
}
},
getFormatDate(dates) {
const d = new Date(dates);
const resDate =
d.getFullYear() +
"-" +
this.p(d.getMonth() + 1) +
"-" +
this.p(d.getDate()) +
" 00:00:01";
return resDate;
wfstatu: 1,
};
},
getFormatDateEnd(dates) {
const d = new Date(dates);
const resDate =
d.getFullYear() +
"-" +
this.p(d.getMonth() + 1) +
"-" +
this.p(d.getDate()) +
" 23:59:59";
return resDate;
mounted() {
let params = {
id: "123327da-42b3-41f6-b785-cf933f137a95",
};
this.$api.get(`${workflowUrl}/schema/getbyid`, params).then((res) => {
if (res.success) {
let wfStatus = res.result.status;
if (wfStatus == 0) {
this.wfstatu = 1;
} else {
this.wfstatu = 3;
}
}
});
this.loadTree();
},
p(s) {
return s < 10 ? "0" + s : s;
methods: {
handleSubmit() {
this.$refs.formValidate.validate((v) => {
if (v) {
this.orderSearchForm.status = this.wfstatu;
Api.mesplancreate(this.orderSearchForm)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.resetFields();
this.$emit("on-close");
},
l(key) {
key = "mes_plan" + "." + key;
return this.$t(key);
},
handleSelect(data) {
// console.log(data);
if (data.length > 0) {
this.selectdata = [];
this.selectdata = data;
this.list = [];
this.list.push({
label: data[0].title,
value: data[0].id
});
if (data[0].isProduct == 1) {
this.orderSearchForm.productName = data[0].title;
this.orderSearchForm.productId = data[0].productId;
this.orderSearchForm.drawnNumber = data[0].drawingNo;
this.orderSearchForm.bomId = data[0].bomId;
} else {
this.$Message.error("此节点不是产品,请选择产品节点!");
}
}
},
resetFields() {
this.orderSearchForm = {
productId: null, //产品id
productName: "", //产品名称
drawnNumber: null, //图号
taskType: null, //任务类型
quantity: 1, //数量
taskRequire: "", //任务接点要求
demandStartDate: this.getFormatDate(nowDate), //开始时间
demandFinishDate: this.getFormatDateEnd(tomorrowDate), //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null, //紧急程度
};
},
loadTree() {
//打开新增订单窗口加载产品
this.resetFields();
var sumData = [];
this.$http.order.getallselecttree().then((res) => {
if (res.result) {
for (var i = 0; i < res.result.length; i++) {
sumData = sumData.concat(res.result[i]);
}
this.data1 = sumData;
} else {
this.$Message.error("加载产品树失败!");
}
});
},
renderContent(h, {
root,
node,
data
}) {
let type = "md-folder";
let title = data.title;
if (data.isProduct != 0) {
let version = this.$store.getters.dictionaryByCode(
"material.main.version",
data.version
);
type = "ios-image";
if (version) {
title = data.title + "(" + data.mmcode + "/" + version.name + ")";
} else {
title = data.title + "(" + data.mmcode + ")";
}
}
return h(
"span", {
on: {
click: () => {
let arrTree = [];
arrTree.push(data);
this.handleSelect(arrTree); //手动选择树节点
},
},
},
[
h("Icon", {
props: {
type: type,
},
style: {
marginRight: "8px",
},
}),
h(
"span", {
style: {
color: data.isProduct == 0 ? "#000" : "rgba(38, 128, 235, 1)",
},
},
title
),
]
);
},
//时间相关start
getStartDate(value) {
if (value == "") {
this.orderSearchForm.demandStartDate = this.getFormatDate(nowDate);
} else {
this.orderSearchForm.demandStartDate = this.getFormatDate(value);
}
},
getFinishedDate(value) {
if (value == "") {
this.orderSearchForm.demandFinishDate = this.getFormatDateEnd(
tomorrowDate
);
} else {
this.orderSearchForm.demandFinishDate = this.getFormatDateEnd(value);
}
},
getFormatDate(dates) {
const d = new Date(dates);
const resDate =
d.getFullYear() +
"-" +
this.p(d.getMonth() + 1) +
"-" +
this.p(d.getDate()) +
" 00:00:01";
return resDate;
},
getFormatDateEnd(dates) {
const d = new Date(dates);
const resDate =
d.getFullYear() +
"-" +
this.p(d.getMonth() + 1) +
"-" +
this.p(d.getDate()) +
" 23:59:59";
return resDate;
},
p(s) {
return s < 10 ? "0" + s : s;
},
//时间相关end
},
//时间相关end
},
};
</script>
......@@ -552,7 +552,7 @@ export default {
methods: {
getRules() {
let ruleInfos = this.$u.makeRules()
console.log(ruleInfos)
// console.log(ruleInfos)
//alert(JSON.stringify(ruleInfos))
},
addOk() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment