<template>
|
<div class="order viewWrap">
|
<h2>订单管理</h2>
|
<ProductList ref="productList"></ProductList>
|
<!-- 搜索功能区 -->
|
<div class="wrap">
|
<div class="searchWrap" style="padding-bottom: 6px;">
|
<div class="searchItem">
|
<span class="searchTitle">订单名称</span>
|
<el-input v-model="name" placeholder="请输入内容" clearable style="width:220px;"></el-input>
|
</div>
|
<div class="searchItem">
|
<span class="searchTitle">甲方名称</span>
|
<el-input v-model="customerName" placeholder="请输入内容" clearable style="width:220px;"></el-input>
|
</div>
|
<div class="searchItem">
|
<span class="searchTitle">项目名称</span>
|
<el-input v-model="projectName" placeholder="请输入内容" clearable style="width:220px;"></el-input>
|
</div>
|
</div>
|
<div class="searchWrap">
|
<div class="searchItem">
|
<span class="searchTitle">负责人</span>
|
<el-input v-model="director" placeholder="请输入内容" clearable style="width:220px;"></el-input>
|
</div>
|
<div class="searchItem">
|
<span class="searchTitle">开始日期</span>
|
<el-date-picker v-model="startDate" value-format="yyyy-MM-dd" type="date" style="width:220px;"
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
<div class="searchItem">
|
<span class="searchTitle">结束日期</span>
|
<el-date-picker v-model="endDate" value-format="yyyy-MM-dd" type="date" style="width:220px;"
|
placeholder="选择日期">
|
</el-date-picker>
|
</div>
|
<div class="searchButton">
|
<el-button type="primary" @click="onGetSearchData">查询</el-button>
|
<el-button @click="onClearSearchData">清空</el-button>
|
</div>
|
</div>
|
</div>
|
|
<!-- 数据功能按钮区 -->
|
<el-button type="primary" icon="el-icon-plus" style="width: 100px; margin-top: 20px;"
|
@click="handleFormDataAdd">添加</el-button>
|
|
<!-- 数据表格区 -->
|
<el-table stripe :data="tableData" height="0" style="margin-top: 20px;">
|
<el-table-column type="expand">
|
<template slot-scope="props">
|
<el-form label-position="left" v-for="item, index in props.row.items" :key="index" inline
|
class="demo-table-expand">
|
<el-form-item label="产品">
|
<span>{{ item.name }}</span>
|
</el-form-item>
|
<el-form-item label="型号">
|
<span>{{ item.proType }}</span>
|
</el-form-item>
|
<el-form-item label="数量">
|
<span>{{ item.number }}</span>
|
</el-form-item>
|
<el-form-item label="完成数量">
|
<span>{{ item.completeNumber }}</span>
|
</el-form-item>
|
<el-form-item label="完成率">
|
<span>{{ item.completeRate }}</span>
|
</el-form-item>
|
</el-form>
|
</template>
|
</el-table-column>
|
<el-table-column type="index" label="序号"> </el-table-column>
|
<el-table-column prop="status" label="状态" width="100">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.status == 1" type="success">
|
<i class="iconfont icon-kaishi" style="font-size: 12px;"></i>
|
执行中
|
</el-tag>
|
<el-tag v-if="scope.row.status == 0" type="warning">
|
<i class="iconfont icon-zanting" style="font-size: 12px;"></i>
|
暂停
|
</el-tag>
|
<el-tag v-if="scope.row.status == -1" type="danger">
|
<i class="iconfont icon-jieshu" style="font-size: 12px;"></i>
|
结束
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="id" label="订单号"> </el-table-column>
|
<el-table-column prop="name" label="订单名称"> </el-table-column>
|
<el-table-column prop="projectName" label="项目名称"> </el-table-column>
|
<el-table-column prop="director" label="负责人" width="160"> </el-table-column>
|
<el-table-column prop="dMobile" label="负责人电话" width="160"> </el-table-column>
|
<el-table-column prop="deliveryDate" label="交付日期" width="100"> </el-table-column>
|
<el-table-column prop="dt" label="创建时间" width="160">
|
</el-table-column>
|
<el-table-column label="操作" width="100">
|
<template slot-scope="scope">
|
<el-button icon="el-icon-edit" @click.native.prevent="handleFormDataEdit(scope.row)" type="text" size="small">
|
编辑
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页组件 -->
|
<el-pagination style="margin-top: 20px;" @size-change="onGetTableData" @current-change="onGetTableData"
|
:current-page.sync="pageCurr" :page-size.sync="pageSize" :page-sizes="[10, 20, 50, 100]"
|
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
</el-pagination>
|
|
<!-- 表单 -->
|
<el-dialog :title="dialogTitle" :visible.sync="showFromData" width="1140px" :before-close="handleFormDataClose">
|
<el-form :model="formData" :rules="formRules" ref="formData" inline class="form-style" label-width="140px">
|
<el-form-item label="ID" prop="id" style="display: none;">
|
<el-input style="width:220px" v-model="formData.id" disabled></el-input>
|
</el-form-item>
|
<el-form-item label="订单名称" prop="name">
|
<el-input style="width:220px" v-model="formData.name" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="甲方名称" prop="customerName">
|
<el-input style="width:220px" v-model="formData.customerName" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="项目名称" prop="projectName">
|
<el-input style="width:220px" v-model="formData.projectName" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="负责人" prop="director">
|
<el-input style="width:220px" v-model="formData.director" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="负责人电话" prop="dMobile">
|
<el-input style="width:220px" v-model="formData.dMobile" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="交付日期" prop="deliveryDate">
|
<el-date-picker v-model="formData.deliveryDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="订单状态" prop="status">
|
<el-select style="width:220px" v-model="formData.status" placeholder="请选择">
|
<el-option label="正常" :value="1"></el-option>
|
<el-option label="暂停" :value="0"></el-option>
|
<el-option label="结束" :value="-1"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input style="width:220px" v-model="formData.remark" clearable></el-input>
|
</el-form-item>
|
</el-form>
|
<el-button icon="el-icon-plus" @click="handleAddItem" type="text" size="small" style="margin: 20px 0 10px 82px;">
|
添加产品
|
</el-button>
|
<el-form inline label-width="140px" v-for="item, index in formData.items" :key="index">
|
<el-form-item label="产品">
|
<el-select style="width:530px" @focus="onShowProductList(index)" :ref="`productList${index}`" v-model="formData.items[index].proId" placeholder="请选择">
|
<el-option v-for="item in selectData" :key="item.id" :label="`${item.name} / ${item.type}`" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="数量">
|
<el-input-number style="width:220px" v-model="formData.items[index].number" :min="1"></el-input-number>
|
</el-form-item>
|
<el-form-item>
|
<el-button icon="el-icon-delete" @click="handleDelItem(index)" type="text" size="small"
|
style="margin-left: 20px;" />
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleFormDataClose">取 消</el-button>
|
<el-button type="primary" @click="handleFormDataSubmit">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style lang="less" scoped>
|
.order {
|
padding: 20px;
|
}
|
|
.demo-table-expand {
|
font-size: 0;
|
}
|
|
.demo-table-expand label {
|
width: 90px;
|
color: #99a9bf;
|
}
|
|
.demo-table-expand .el-form-item {
|
margin-right: 0;
|
margin-bottom: 0;
|
width: 20%;
|
}
|
|
.demo-table-expand {
|
border-bottom: 1px dashed #ccc;
|
background-color: #f9f9f9;
|
padding-left: 10px;
|
}
|
|
.demo-table-expand:first-child {
|
border-top: 1px dashed #ccc;
|
}
|
|
|
.form-style .el-form-item {
|
margin-right: 0;
|
margin-bottom: 0;
|
width: 33%;
|
margin-bottom: 30px;
|
}
|
|
.form-style {
|
border-bottom: 1px dashed #ccc;
|
}
|
</style>
|
|
<script>
|
import ProductList from '@/components/ProductList'
|
export default {
|
name: "order",
|
components: { ProductList },
|
data() {
|
return {
|
name: null,
|
customerName: null,
|
projectName: null,
|
director: null,
|
startDate: null,
|
endDate: null,
|
pageSize: 10,
|
pageCurr: 1,
|
total: 0,
|
tableData: [],
|
showFromData: false,
|
formData: {
|
id: null,
|
name: null,
|
customerName: null,
|
projectName: null,
|
director: null,
|
dMobile: null,
|
deliveryDate: null,
|
remark: null,
|
items: [],
|
status: 1,
|
},
|
formRules: {
|
name: [{ required: true, message: "必填项", trigger: "blur" }],
|
customerName: [{ required: true, message: "必填项", trigger: "blur" }],
|
projectName: [{ required: true, message: "必填项", trigger: "blur" }],
|
director: [{ required: true, message: "必填项", trigger: "blur" }],
|
dMobile: [{ required: true, message: "必填项", trigger: "blur" }],
|
deliveryDate: [{ required: true, message: "必填项", trigger: "blur" }],
|
remark: [{ required: false, message: "必填项", trigger: "blur" }],
|
status: [{ required: true, message: "必填项", trigger: "blur" }],
|
},
|
selectData: [],
|
processData: [],
|
dialogTitle: null,
|
|
showCodeList: false,
|
batchId: null,
|
planId: null,
|
codeList: [],
|
codeListPageSize: 10,
|
codeListPageCurr: 1,
|
codeListTotal: 0,
|
addNum: null,
|
showCode: false,
|
imgBase64: null,
|
};
|
},
|
computed: {},
|
watch: {
|
|
},
|
mounted() {
|
this.onGetTableData();
|
this.onGetSelectData();
|
},
|
methods: {
|
// 执行条件查询
|
onGetSearchData: function () {
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 清空查询条件
|
onClearSearchData: function () {
|
this.name = null;
|
this.customerName = null;
|
this.projectName = null;
|
this.director = null;
|
this.startDate = null;
|
this.endDate = null;
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 获取表格数据
|
onGetTableData: function () {
|
var that = this;
|
var data = {
|
name: this.name,
|
customerName: this.customerName,
|
projectName: this.projectName,
|
director: this.director,
|
startDate: this.startDate,
|
endDate: this.endDate,
|
pageSize: this.pageSize,
|
pageCurr: this.pageCurr,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "production/order/some",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.tableData = res.content.obj;
|
that.total = res.content.itemTotal;
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 添加
|
handleFormDataAdd: function () {
|
this.onGetSelectData();
|
this.formData.id = null;
|
this.formData.name = null;
|
this.formData.customerName = null;
|
this.formData.projectName = null;
|
this.formData.director = null;
|
this.formData.dMobile = null;
|
this.formData.deliveryDate = null;
|
this.formData.status = 1;
|
this.formData.remark = null;
|
this.formData.items = [];
|
this.showFromData = true;
|
this.dialogTitle = "添加订单";
|
},
|
// 关闭
|
handleFormDataClose: function () {
|
this.formData.id = null;
|
this.formData.name = null;
|
this.formData.customerName = null;
|
this.formData.projectName = null;
|
this.formData.director = null;
|
this.formData.dMobile = null;
|
this.formData.deliveryDate = null;
|
this.formData.status = null;
|
this.formData.remark = null;
|
this.formData.items = [];
|
this.dialogTitle = null;
|
this.showFromData = false;
|
this.$refs["formData"].resetFields();
|
},
|
// 编辑
|
handleFormDataEdit: function (row) {
|
this.onGetSelectData();
|
this.formData.id = row.id;
|
this.formData.name = row.name;
|
this.formData.customerName = row.customerName;
|
this.formData.projectName = row.projectName;
|
this.formData.director = row.director;
|
this.formData.dMobile = row.dMobile;
|
this.formData.deliveryDate = row.deliveryDate;
|
this.formData.status = row.status;
|
this.formData.remark = row.remark;
|
this.formData.items = JSON.parse(JSON.stringify(row.items));
|
this.showFromData = true;
|
this.dialogTitle = "编辑订单";
|
},
|
// 添加订单产品
|
handleAddItem: function () {
|
this.formData.items.unshift({
|
proId: null,
|
number: null,
|
})
|
},
|
// 删除订单产品
|
handleDelItem: function (index) {
|
this.formData.items.splice(index, 1);
|
},
|
// 提交数据确认
|
handleFormDataSubmit: function () {
|
this.$confirm(`此操作将保存并更新数据, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onFormDataSubmit();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 提交数据
|
onFormDataSubmit: function () {
|
var that = this;
|
var url, data;
|
if (this.formData.id) {
|
url = "production/order/update";
|
data = {
|
id: this.formData.id,
|
name: this.formData.name,
|
customerName: this.formData.customerName,
|
projectName: this.formData.projectName,
|
director: this.formData.director,
|
dMobile: this.formData.dMobile,
|
deliveryDate: this.formData.deliveryDate,
|
status: this.formData.status,
|
remark: this.formData.remark,
|
items: this.formData.items,
|
};
|
} else {
|
url = "production/order/save";
|
data = {
|
name: this.formData.name,
|
customerName: this.formData.customerName,
|
projectName: this.formData.projectName,
|
director: this.formData.director,
|
dMobile: this.formData.dMobile,
|
deliveryDate: this.formData.deliveryDate,
|
status: this.formData.status,
|
remark: this.formData.remark,
|
items: this.formData.items,
|
};
|
}
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: url,
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
that.handleFormDataClose();
|
that.onGetTableData();
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 状态变更确认
|
handleStatus(row, status, msg) {
|
this.$confirm(`此操作将 ${msg} 该任务, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onStatus(row, status);
|
})
|
.catch(() => {
|
this.onGetTableData();
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 执行状态变更
|
onStatus: function (row, status) {
|
var that = this;
|
var data = {
|
id: row.id,
|
status: status,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "production/assembly/updateStatus",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
that.onGetTableData();
|
})
|
.catch((err) => {
|
console.log(err);
|
that.onGetTableData();
|
});
|
},
|
// 获取产品数据
|
onGetSelectData: function () {
|
var that = this;
|
that
|
.$axiosAdmin({
|
method: "get",
|
url: "platform/product/all",
|
})
|
.then((res) => {
|
if (res.success == true) {
|
this.selectData = res.content;
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 获取流程数据
|
onGetProcessData: function () {
|
var that = this;
|
var data = {
|
proId: this.formData.proId,
|
};
|
that
|
.$axiosAdmin({
|
method: "get",
|
url: "production/process/queryAll",
|
params: data,
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.processData = res.content;
|
var unmatched = true;
|
that.processData.forEach((item) => {
|
if (that.formData.processId == item.id) {
|
unmatched = false;
|
}
|
});
|
if (unmatched) {
|
that.formData.processId = null;
|
}
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
onShowProductList: function (index) {
|
let ref = eval('this.$refs.productList' + index)[0]
|
ref.blur()
|
this.$refs.productList.show((res) => {
|
if (!res) return;
|
this.formData.items[index].proId = res.id
|
})
|
},
|
},
|
};
|
</script>
|