123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <template>
- <div class="detail-container">
- <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
- <div class="main-title">
- <div class="title">工程信息单</div>
- </div>
- <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="100px" size="small" label-position="left">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="工程信息单" prop="orderNum">
- <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" readonly></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
- <el-form-item label="单据日期" prop="orderDate">
- <el-date-picker
- v-model="mainForm.orderDate"
- type="date"
- value-format="yyyy-MM-dd"
- style="width: 100%;"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="产品大类" prop="mainId">
- <el-select v-model="mainForm.mainId" placeholder="选择产品大类" style="width: 100%">
- <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="经销商编码" prop="jxsNum">
- <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" readonly></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="项目名称" prop="enginName">
- <el-input v-model="mainForm.enginName" placeholder="请输入项目名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="单据类型" prop="orderType">
- <el-input v-model="mainForm.orderType" placeholder="请输入单据类型"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="经销商名称" prop="jxsName">
- <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" readonly></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="使用单位" prop="company">
- <el-input v-model="mainForm.company" placeholder="请输入使用单位"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="安装地址" prop="address">
- <el-input v-model="mainForm.address" placeholder="请输入安装地址"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="工程编号" prop="enginNum">
- <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="厂工程编码" prop="factoryNum">
- <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="工程登录类型" prop="loginType">
- <el-input v-model="mainForm.loginType" placeholder="请输入工程登录类型"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="16">
- <el-form-item label="备注" prop="remark">
- <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="业务员" prop="salesMan">
- <el-input v-model="mainForm.salesMan" placeholder="请输入业务员" readonly></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="制单人" prop="createMan">
- <el-input v-model="mainForm.createMan" placeholder="请输入制单人" readonly></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
- <el-form-item label="制单日期" prop="createDate">
- <el-date-picker
- v-model="mainForm.createDate"
- type="date"
- readonly
- value-format="yyyy-MM-dd"
- style="width: 100%;"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
- <el-form-item label="合同有效期" prop="contractDate">
- <el-date-picker
- v-model="mainForm.contractDate"
- type="date"
- value-format="yyyy-MM-dd"
- style="width: 100%;"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="main-title">
- <div class="title">货品信息</div>
- </div>
- <div class="table" style="margin-top: 20px">
- <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
- <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
- <el-table-column align="center" label="销售类型" prop="saleTypeId" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-select v-model="scope.row.saleTypeId" placeholder="选择销售类型" size="small" @change="changeSaleType(scope.$index)">
- <el-option
- v-for="item in salesTypeList"
- :key="item.id"
- :label="item.saleName"
- :value="item.id">
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="center" label="产品名称" prop="materialNumber" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-select v-model="scope.row.materialNumber" placeholder="选择产品" size="small" @change="changeGoods(scope.$index)">
- <el-option
- v-for="item in retailProductList"
- :key="item.number"
- :label="item.name"
- :value="item.number">
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="单位" prop="baseUnitId" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.price" size="small" type="number"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- {{(scope.row.price || 0) * (scope.row.qty || 0)}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.remark" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="操作" width="100" fixed="right">
- <template slot-scope="scope">
- <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="add"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加产品</el-button></div>
- </div>
-
- <div class="page-footer">
- <div class="footer" :class="classObj">
- <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
- <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
- <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
- <el-button slot="reference">关 闭</el-button>
- </el-popconfirm>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from "@/api/supply/engin";
- import { getDictList, getTypeList } from '@/api/common'
- export default {
- name: 'EnginForm',
- componentName: 'EnginForm',
- props: ['listItem'],
- data() {
- return {
- goodsList: [],
- mainForm: {
- orderNum: '',
- orderDate: '',
- mainId: '102',
- jxsNum: '',
- enginName: '',
- orderType: '',
- jxsName: '',
- company: '',
- address: '',
- enginNum: '',
- factoryNum: '',
- loginType: '',
- remark: '',
- salesMan: '',
- createMan: '',
- createDate: '',
- contractDate: '',
- },
- mainFormRules: {
- orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
- jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
- enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
- jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
- company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
- address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
- },
- typeList: [],
- salesTypeList: [],
- retailProductList: [],
- }
- },
- computed: {
- sidebar() {
- return this.$store.state.app.sidebar
- },
- classObj() {
- return {
- hideSidebar: !this.sidebar.opened,
- openSidebar: this.sidebar.opened
- }
- },
-
- },
- created() {
- this.getDictList();
- this.getTypeList();
- this.getRetailProductList();
- if(this.listItem) {
- this.getDetail();
- }else {
- this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerId;
- this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
- this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
- this.mainForm.createDate = this.getDate(0);
- this.mainForm.contractDate = this.getDate(1);
- }
- },
- methods: {
- // 返回列表
- goBack() {
- this.$emit('backListFormDetail');
- },
- getDate(addYear) {
- var date = new Date();
- var seperator1 = "-";
- var year = date.getFullYear() + addYear;
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = year + seperator1 + month + seperator1 + strDate;
- return currentdate;
- },
- // 获取详情
- getDetail() {
- getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
- let data = res.data;
- this.mainForm.orderNum = data.enginInfoNo;
- this.mainForm.orderDate = data.orderDate;
- this.mainForm.mainId = data.productCategoryId;
- this.mainForm.jxsNum = data.customerId;
- this.mainForm.enginName = data.projectName;
- this.mainForm.orderType = data.orderType;
- this.mainForm.jxsName = data.customerName;
- this.mainForm.company = data.useUnit;
- this.mainForm.address = data.installAddress;
- this.mainForm.enginNum = data.projectNo;
- this.mainForm.factoryNum = data.enginFactoryNo;
- this.mainForm.loginType = data.enginSignType;
- this.mainForm.remark = data.remark;
- this.mainForm.salesMan = data.serviceId;
- this.mainForm.createMan = data.createName;
- this.mainForm.createDate = data.createTime;
- this.mainForm.contractDate = data.contractExpireDate;
- this.goodsList = data.items;
- })
- },
- // 获取产品大类列表
- getDictList() {
- getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
- this.typeList = res.data;
- })
- },
- // 获取销售类型列表
- getTypeList() {
- getTypeList({
- pageNum: 1,
- pageSize: -1,
- }).then((res) => {
- this.salesTypeList = res.data.records;
- });
- },
- // 获取商品列表
- getRetailProductList() {
- getRetailProductList({
- pageNum: 1,
- pageSize: -1,
- }).then(res => {
- this.retailProductList = res.data.records;
- })
- },
- // 修改销售类型
- changeSaleType(index) {
- if(this.goodsList[index].saleTypeId) {
- let obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId);
- this.goodsList[index].saleTypeName = obj.saleName;
- this.goodsList[index].saleTypeCode = obj.saleCode;
- }
- },
- // 修改产品
- changeGoods(index) {
- if(this.goodsList[index].materialNumber) {
- let obj = this.retailProductList.find(o => o.number == this.goodsList[index].materialNumber);
- this.goodsList[index].materialName = obj.name;
- this.goodsList[index].materialId = obj.materialId;
- this.goodsList[index].specification = obj.specification;
- this.goodsList[index].baseUnitId = obj.baseUnit;
- this.goodsList[index].price = obj.batchPrice;
- this.goodsList[index].taxRate = obj.taxRate;
- this.goodsList[index].mainId = obj.mainId;
- }
- },
- // 添加产品
- addGoods() {
- this.goodsList.push({})
- },
- // 删除产品
- deleteItem(index) {
- this.goodsList.splice(index, 1);
- },
- clickSubmitForm(type) {
- this.$refs.mainForm.validate((valid) => {
- if (valid) {
- for(let i=0; i<this.goodsList.length; i++) {
- if(!this.goodsList[i].saleTypeId) {
- this.$errorMsg('请选择销售类型');
- return;
- }
- }
- for(let i=0; i<this.goodsList.length; i++) {
- if(!this.goodsList[i].materialNumber) {
- this.$errorMsg('请选择产品');
- return;
- }
- }
- for(let i=0; i<this.goodsList.length; i++) {
- if(!this.goodsList[i].qty) {
- this.$errorMsg('请输入数量');
- return;
- }
- }
- let params = {
- orderDate: this.mainForm.orderDate + ' 00:00:00',
- productCategoryId: this.mainForm.mainId,
- projectName: this.mainForm.enginName,
- orderType: this.mainForm.orderType,
- useUnit: this.mainForm.company,
- installAddress: this.mainForm.address,
- projectNo: this.mainForm.enginNum,
- enginFactoryNo: this.mainForm.factoryNum,
- enginSignType: this.mainForm.loginType,
- remark: this.mainForm.remark,
- contractExpireDate: this.mainForm.contractDate,
- items: this.goodsList
- }
- if(type === 1) {
- if(this.listItem) {
- params.enginInfoId = this.listItem.enginInfoId;
- editEngin(params).then(res => {
- this.$successMsg('编辑成功');
- this.goBack();
- this.$parent.getList();
- })
- }else {
- addEngin(params).then(res => {
- this.$successMsg('保存成功');
- this.goBack();
- this.$parent.getList();
- })
- }
- }else {
- if(this.listItem) {
- params.enginInfoId = this.listItem.enginInfoId;
- }
- submitEngin(params).then(res => {
- this.$successMsg('提交审核成功');
- this.goBack();
- this.$parent.getList();
- })
- }
- }
- })
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .detail-container {
- width: 100%;
- height: 100%;
- }
- .main-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 20px;
- height: 60px;
- border-bottom: 1px solid #DCDFE6;
- margin-bottom: 20px;
- .title {
- font-size: 16px;
- font-weight: 600;
- padding-left: 10px;
- }
- }
- .add {
- display: flex;
- align-items: center;
- justify-content: center;
- border: 1px solid #EBEEF5;
- border-top: none;
- height: 50px;
- }
- ::v-deep input::-webkit-outer-spin-button,
- ::v-deep input::-webkit-inner-spin-button {
- -webkit-appearance: none;
- }
- ::v-deep input[type='number'] {
- -moz-appearance: textfield;
- }
- </style>
|