<!--商机报备表单--> <template> <div class="report-container"> <div class="report-title"> 基础报备 </div> <div class="report-from"> <div class="from-title"> 基础信息 </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.itemName" title="项目名称" placeholder="请输入项目名称" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.itemBudget" title="项目预算" placeholder="请输入项目预算" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue title="预计工期" class="inputWidth"> <el-date-picker v-model="addInfo.itemDuration" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width:380px" /> </inputVue> </div> </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.itemManager" title="商机负责人" placeholder="请输入商机负责人姓名" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.phone" title="联系方式" placeholder="请输入联系方式" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.organization" title="单位组织" placeholder="请输入单位组织" class="inputWidth" width="380px" /> </div> </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue title="商机状态" class="inputWidth"> <el-select v-model="addInfo.status" clearable placeholder="请选择" style="width:380px"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> </el-select> </inputVue> </div> <div class="input-item"> <RedStar /> <inputVue title="项目地址" class="inputWidth"> <el-select v-model="addInfo.itemProvince" clearable placeholder="省/市" style="width:150px;margin-left: 55px;" @change="provinceChange" > <el-option v-for="item in form.provinceList" :key="item.id" :label="item.areaName" :value="item.areaName" /> </el-select> </inputVue> <inputVue title="" class="inputWidth"> <el-select v-model="addInfo.itemCity" clearable placeholder="市/区" style="width:150px" @change="cityChange($event)" > <el-option v-for="item in form.cityList" :key="item.id" :label="item.areaName" :value="item.areaName" /> </el-select> </inputVue> <inputVue title="" class="inputWidth"> <el-select v-model="addInfo.itemArea" clearable placeholder="县/街道" style="width:150px"> <el-option v-for="item in form.countyList" :key="item.id" :label="item.areaName" :value="item.areaName" /> </el-select> </inputVue> <inputVue v-model="addInfo.itemAddress" placeholder="请输入详细地址" class="inputWidth" width="440px" /> </div> </div> </div> <div class="report-from"> <div class="from-title"> 关联方信息 </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.ownerName" title="业主方名称" placeholder="请输入名称" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.ownerContacts" title="业主方联系人" placeholder="请输入联系人" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.ownerPhone" title="业主方联系方式" placeholder="请输入联系方式" class="inputWidth" width="380px" /> </div> </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.contractName" title="总包方名称" placeholder="请输入名称" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.contractContacts" title="总包方联系人" placeholder="请输入联系人" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.contractPhone" title="总包方联系方式" placeholder="请输入联系方式" class="inputWidth" width="380px" /> </div> </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.constructName" title="施工方名称" placeholder="请输入名称" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.constructContacts" title="施工方联系人" placeholder="请输入联系人" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.constructPhone" title="施工方联系方式" placeholder="请输入联系方式" class="inputWidth" width="380px" /> </div> </div> <div class="from-inputBox"> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.agentName" title="代理商名称" placeholder="请输入名称" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.agentContacts" title="代理商联系人" placeholder="请输入联系人" class="inputWidth" width="380px" /> </div> <div class="input-item"> <RedStar /> <inputVue v-model="addInfo.agentPhone" title="代理商联系方式" placeholder="请输入联系方式" class="inputWidth" width="380px" /> </div> </div> </div> <div class="report-from"> <div class="from-title"> 产品信息 </div> <div class="from-table"> <div style="margin-left: 2px;"> <el-table ref="tb" :data="addInfo.productList" border class="el-tab" style="width: 100%;"> <el-table-column type="index" label="序号" width="50px" /> <el-table-column prop="brandName" label="产品品牌" width="250px"> <template slot-scope="{row,$index}"> <span v-if="!showEdit[$index]">{{ row.brandName }}</span> <!-- <el-input v-if="showEdit[$index]" v-model="addInfo.productList.brandName" placeholder="请输入产品品牌"> </el-input> --> <el-select v-if="showEdit[$index]" v-model="brandName" clearable placeholder="请输入产品品牌"> <el-option v-for="item in brandList" :key="item.brandCode" :label="item.brandName" :value="item.brandName" /> </el-select> </template> </el-table-column> <el-table-column prop="categoryIds" label="产品品类" width="250px"> <template slot-scope="{row,$index}"> <span v-if="!showEdit[$index]">{{ row.categoryIds }}</span> <!-- <el-input v-if="showEdit[$index]" v-model="addInfo.productList.categoryIds" placeholder="请输入产品品类"> </el-input> --> <el-select v-if="showEdit[$index]" v-model="categoryIds" clearable placeholder="请输入产品品类" @change="categoryIdChange" > <el-option v-for="item in categoryList" :key="item.id" :label="item.categoryName" :value="item.categoryName" /> </el-select> </template> </el-table-column> <el-table-column prop="productCode" label="产品型号" width="250px"> <template slot-scope="{row,$index}"> <span v-if="!showEdit[$index]">{{ row.productCode }}</span> <!-- <el-input v-if="showEdit[$index]" v-model="addInfo.productList.productCode" placeholder="请输入产品型号"> </el-input> --> <el-select v-if="showEdit[$index]" v-model="addInfo.productList.productCode" clearable placeholder="请输入产品型号" > <el-option v-for="item in CodeList" :key="item.id" :label="item.productCode" :value="item.productCode" /> </el-select> </template> </el-table-column> <el-table-column prop="productQuantity" label="产品数量" width="250px"> <template slot-scope="{row,$index}"> <span v-if="!showEdit[$index]">{{ row.productQuantity }}</span> <el-input v-if="showEdit[$index]" v-model="addInfo.productList.productQuantity" placeholder="请输入产品数量" /> </template> </el-table-column> <el-table-column prop="productPrice" label="产品单价" width="250px"> <template slot-scope="{row,$index}"> <span v-if="!showEdit[$index]">{{ row.productPrice }}</span> <el-input v-if="showEdit[$index]" v-model="addInfo.productList.productPrice" placeholder="请输入产品单价" /> </template> </el-table-column> <el-table-column header-align="center" align="center" width="100" label="操作"> <template slot-scope="{row,$index}"> <el-button v-if="!showEdit[$index]" type="text" size="small" @click="showUpdate($index, row)"> 编辑 </el-button> <el-button v-if="showEdit[$index]" type="text" size="small" style="color: #85ce61;" @click="submit($index, row)" > 确定 </el-button> <el-button v-if="showEdit[$index]" type="text" size="small" style="color: red;" @click="cancelUpdate($index)" > 取消 </el-button> </template> </el-table-column> </el-table> </div> <div> <el-button class="table-btn" @click="handleAddBtn"> 添加项目需求 </el-button> </div> </div> </div> <div class="btnBox"> <el-button type="primary" class="save" @click="save"> 保存 </el-button> <el-button type="info" class="close" @click="close"> 取消 </el-button> </div> </div> </template> <script> import RedStar from '../../components/mycomponent/redStar.vue' import inputVue from '../../components/mycomponent/input/inputVue.vue' import { list } from '../../api/product/product' import { C_list } from '../../api/product/category' import { SelectList } from '../../api/product/brand' import { add } from '../../api/business/business' import { order_area } from '../../api/order/order' import { Message } from 'element-ui' export default { components: { RedStar, inputVue }, data() { return { brandName: '', categoryIds: '', CodeList: [], brandList: [], categoryList: [], checkedDetail: [], showEdit: [], options: [ { value: '0', label: '推进' }, { value: '1', label: '成交' }, { value: '2', label: '丢失' } ], addInfo: { itemName: '', itemBudget: '', itemDuration: '', itemManager: '', phone: '', organization: '', status: '', itemProvince: '', itemCity: '', itemArea: '', itemAddress: '', ownerName: '', // 业主方 ownerContacts: '', ownerPhone: '', contractName: '', // 总包方 contractContacts: '', contractPhone: '', constructName: '', // 施工方 constructContacts: '', constructPhone: '', agentName: '', // 代理商 agentContacts: '', agentPhone: '', productList: [] }, form: { provinceList: [], cityList: [], countyList: [] } } }, watch: { addInfo: { handler(newval, oldval) { console.log(newval, oldval) if (!this.addInfo.itemProvince) { this.addInfo.itemCity = '' this.addInfo.itemArea = '' } else if (!this.addInfo.itemCity) { this.addInfo.itemArea = '' } }, deep: true, immediate: true } }, created() { order_area('pid=0', {}).then((res) => { console.log(res, 'Sheng') this.form.provinceList = res }) }, mounted() { }, methods: { save() { this.addInfo.productList = { productCode: this.addInfo.productList.productCode, productQuantity: this.addInfo.productList.productQuantity, productPrice: this.addInfo.productList.productPrice, productName: '' } add(this.addInfo).then(res => { console.log(res) if (res) { this.$message({ message: '保存成功', type: 'success' }) } }) this.setData() }, close() { this.setData() }, provinceChange(e) { console.log(e) const index = this.form.provinceList.findIndex(item => { return item.areaName == e }) const code = this.form.provinceList[index].id order_area(`pid=${code}`, {}).then((res) => { console.log(res, 'Shi') this.form.cityList = res }) }, cityChange(e) { const index = this.form.cityList.findIndex(item => { return item.areaName == e }) const code = this.form.cityList[index].id order_area(`pid=${code}`, {}).then((res) => { console.log(res, 'Xian') this.form.countyList = res }) }, handleAddBtn() { const obj = {} obj.brandName = '' obj.categoryIds = '' obj.productCode = '' obj.productQuantity = '' obj.productPrice = '' this.addInfo.productList.push(obj) }, showUpdate(index, row) { console.log(index, row) this.showEdit[index] = true this.$set(this.showEdit, index, true) // 这里要用$set方法,否则页面状态不更新 C_list().then(res => { console.log(res, '品类') this.categoryList = res }) SelectList().then(res => { console.log(res, '品牌') this.brandList = res }) }, categoryIdChange(e) { const index = this.categoryList.findIndex(item => { return item.categoryName == e }) console.log(index) const code = this.categoryList[index].id console.log(code) list({ categoryId: code }).then(res => { console.log(res) this.CodeList = res }) }, cancelUpdate(index) { this.$confirm('取消修改?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }) .then(() => { this.$set(this.showEdit, index, false) }) .catch(() => { }) }, submit(index, row) { console.log(row) // 发送请求,隐藏输入框 row.productCode = this.addInfo.productList.productCode row.brandName = this.brandName console.log(this.categoryIds) row.categoryIds = this.categoryIds row.productQuantity = this.addInfo.productList.productQuantity row.productPrice = this.addInfo.productList.productPrice this.$message({ type: 'success', message: '已缓存,记得点击保存提交修改喔!', duration: 888, onClose: () => { this.$set(this.showEdit, index, false) // vue添加属性的方法 } }) }, setData() { this.addInfo = { itemName: '', itemBudget: '', itemDuration: '', itemManager: '', phone: '', organization: '', status: '', itemProvince: '', itemCity: '', itemArea: '', itemAddress: '', ownerName: '', // 业主方 ownerContacts: '', ownerPhone: '', contractName: '', // 总包方 contractContacts: '', contractPhone: '', constructName: '', // 施工方 constructContacts: '', constructPhone: '', agentName: '', // 代理商 agentContacts: '', agentPhone: '', productList: [] } } } } </script> <style lang='scss' scoped> .report-container { .report-title { font-size: 22px; font-weight: bold; margin: 10px 0 10px 20px; } .report-from { .from-title { font-size: 22px; font-weight: bold; background-color: #28739e; color: white; padding: 10px 0 10px 20px; } .from-inputBox { display: flex; margin-left: 20px; .input-item { width: 540px; display: flex; justify-content: space-between; align-items: center; } } .from-table { display: flex; margin: 10px 20px; .table-btn { margin-left: 20px; } } } .btnBox { padding: 30px; box-sizing: border-box; display: flex; align-items: center; justify-content: space-evenly; .save, .close { width: 100px; } } } </style>