From f4ed5ae8873f65c36b5cf37be264f6ec1e154647 Mon Sep 17 00:00:00 2001 From: zuozhengqing <a13193816592@163.com> Date: 星期三, 20 三月 2024 19:36:58 +0800 Subject: [PATCH] 合并分支冲突解决 --- src/components/makepager/TableCommonView.vue | 308 +++++++---- src/api/purchaseManage/purchase.js | 69 +- src/views/supplierManage/supplier/AddNewProduct.vue | 69 +- src/views/purchaseManage/purchase/components/AddPurchase.vue | 145 ++++- src/views/purchaseManage/purchase/index.vue | 276 ++++++++++ src/api/data.js | 66 +- src/components/makepager/CommonFormTableView.vue | 522 +++++++++++++------ src/views/other/commonDialog/SelectCommonDialog.vue | 54 + 8 files changed, 1,071 insertions(+), 438 deletions(-) diff --git a/src/api/data.js b/src/api/data.js index 9678b60..1909a6e 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -1,48 +1,58 @@ // 閲囪喘鐘舵�� -const purchaseStatus=[ - {id:1,name:"寰呯‘璁�"}, - {id:2,name:"寰呭叆搴�"}, - {id:3,name:"宸插叆搴�"}, - {id:4,name:"宸插畬鎴�"}, - {id:5,name:"宸插彇娑�"} +const purchaseStatus = [ + { id: 1, name: "寰呯‘璁�" }, + { id: 2, name: "寰呭叆搴�" }, + { id: 3, name: "宸插叆搴�" }, + { id: 4, name: "宸插畬鎴�" }, + { id: 5, name: "宸插彇娑�" } +] +// 鏀惰揣鐘舵�� +const receiveStatus = [ + { id: 1, name: "寰呯‘璁�" }, + { id: 2, name: "寰呭叆搴�" }, + { id: 3, name: "灏辩华" }, + { id: 4, name: "宸插畬鎴�" }, + { id: 5, name: "宸插彇娑�" } ] // 璐ㄦ鍗曠姸鎬� -const qualityStatus=[ +const qualityStatus = [ { - name:'寰呰川妫�', - id:1, + name: "寰呰川妫�", + id: 1 }, { - name:'宸插畬鎴�', - id:2, + name: "宸插畬鎴�", + id: 2 } ] // 閫�璐у崟鐘舵�� -const returnedStatus=[ +const returnedStatus = [ { - name:'寰呭彂璐�', - id:1, + name: "寰呭彂璐�", + id: 1 }, { - name:'寰呯鏀�', - id:2, + name: "寰呯鏀�", + id: 2 }, { - name:'寰呭彂璐�', - id:3, + name: "寰呭彂璐�", + id: 3 }, { - name:'宸插畬鎴�', - id:4, - }, + name: "宸插畬鎴�", + id: 4 + } ] -export const getDataByType = type => { - if(type =='purchaseStatus'){ - return purchaseStatus; - }else if(type=='qualityStatus'){ - return qualityStatus; - }else if(type=='returnedStatus'){ - return returnedStatus; +export const getDataByType = (type) => { + if (type == "purchaseStatus") { + return purchaseStatus + } else if (type == "qualityStatus") { + return qualityStatus + } else if (type == "returnedStatus") { + return returnedStatus + } else if (type == "receiveStatus") { + return receiveStatus } } diff --git a/src/api/purchaseManage/purchase.js b/src/api/purchaseManage/purchase.js index 73373b2..37a8b1e 100644 --- a/src/api/purchaseManage/purchase.js +++ b/src/api/purchaseManage/purchase.js @@ -49,7 +49,7 @@ method: "get" }) } -// 閲囪喘鍗曞垪琛� +// 閲囪喘鍗曞垪琛� // export const getPurchaseList = async (data) => { // return await axios.get(`/api/purchase/purchaseList`, { // params: data @@ -72,36 +72,36 @@ } // 鏇存柊閲囪喘鍗� export function updatePurchase(data) { - return request({ - url: "/api/purchase/purchase", - method: "put", - data - }) - } + return request({ + url: "/api/purchase/purchase", + method: "put", + data + }) +} // 鑾峰彇閲囪喘鍗曚俊鎭� export function getPurchaseInfo(data) { - return request({ - url: "/api/purchase/purchase/"+data.id, - method: "get", - data - }) - } - // 鍒犻櫎閲囪喘鍗曚俊鎭� + return request({ + url: "/api/purchase/purchase/" + data.id, + method: "get", + data + }) +} +// 鍒犻櫎閲囪喘鍗曚俊鎭� export function deletePurchase(data) { - return request({ - url: "/api/purchase/purchase/"+data.id, - method: "delete", - data - }) - } + return request({ + url: "/api/purchase/purchase/" + data.id, + method: "delete", + data + }) +} // 鎻愪氦閲囪喘鍗� export function submitPurchase(data) { - return request({ - url: "/api/purchase/submit", - method: "post", - data - }) - } + return request({ + url: "/api/purchase/submit", + method: "post", + data + }) +} // 鏂板缓閲囪喘绫诲瀷 export function savePurchaseType(data) { return request({ @@ -123,4 +123,19 @@ return await axios.get(`/api/purchase/qualityInspectList`, { params: data }) -} \ No newline at end of file +} +// 鑾峰彇浠撳簱鍒楄〃 +export function getWarehouseInfo() { + return request({ + url: "/api/purchase/getWarehouseInfo/", + method: "get" + }) +} +// 鑾峰彇浜у搧/鏀惰揣淇℃伅 +export function getOperationInfo(data) { + return request({ + url: "/api/purchase/getOperationInfo/" + data.id, + method: "get", + data + }) +} diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue index eeffb91..145cd11 100644 --- a/src/components/makepager/CommonFormTableView.vue +++ b/src/components/makepager/CommonFormTableView.vue @@ -1,18 +1,28 @@ <template> <div class="page-view"> <el-form ref="form" :model="tableList" :show-message="false" label-position="right"> - <el-table - :data="tableList.tableData" - style="width: 100%" - :show-summary="showSummary.show" - :summary-method="getSummaries" - :span-method="arraySpanMethod" - @row-click="rowClick" + <el-table + ref="fromTable" + :data="tableList.tableData" + :show-summary="showSummary.show" + :summary-method="getSummaries" + :span-method="arraySpanMethod" + style="width: 100%" + @selection-change="handleSelectionChange" + :row-key="(row) => row.productId" > - <el-table-column type="index" v-if="tableList.tableColumn && tableList.tableColumn.length > 0" label="缂栧彿" - width="50" align="center"></el-table-column> - <el-table-column v-for="(item, i) in tableList.tableColumn" :key="i" :prop="item.prop" :label="item.label" - :width="item.width" :min-width="item.min" align="center"> + <el-table-column v-if="selectBox" type="selection" :reserve-selection="true" width="40" align="center"> + </el-table-column> + <el-table-column v-if="tableList.isReturn" type="index" label="#" width="50" align="center"></el-table-column> + <el-table-column + v-for="(item, i) in tableList.tableColumn" + :key="i" + :prop="item.prop" + :label="item.label" + :width="item.width" + :min-width="item.min" + align="center" + > <!-- 琛ㄥご鏍峰紡 --> <template slot="header"> <span v-if="item.isRequird" style="color: #f56c6c">*</span> @@ -20,81 +30,187 @@ </template> <!-- column鏍峰紡 --> <template slot-scope="scope"> - <!-- <template v-if="!detailEnter"> --> - <el-form-item v-if="item.input" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop" - :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]"> - <el-input :disabled="item.disabled" v-model.trim="scope.row[item.prop]" maxlength="50" size="mini" @change="(val) => { - commonInputChange(val, item.prop, scope.row) - } - "></el-input> - </el-form-item> - <el-form-item v-else-if="item.productName" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"> - <div class="custom-name"> - <el-autocomplete :disabled="item.disabled" v-model="scope.row[item.prop]" - :fetch-suggestions="querySearchAsync" value-key="name" style="width: calc(100% - 70px)" size="mini" - @select="(val) => { - handleSelectClient(val, item.prop, scope.row) - } - "></el-autocomplete> - <div v-if="!item.disabled" class="common-select-btn" @click="selClientClick(scope.row, item.prop, scope)"> - <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i> + <template v-if="!detailEnter || isOperate"> + <el-form-item + v-if="item.input" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]" + > + <el-input + v-model.trim="scope.row[item.prop]" + maxlength="50" + size="mini" + :disabled="!isOperate" + @change=" + (val) => { + commonInputChange(val, item.prop, scope.row, scope) + } + " + ></el-input> + </el-form-item> + <el-form-item + v-else-if="item.productName" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + > + <div class="custom-name"> + <el-autocomplete + v-model="scope.row[item.prop]" + :fetch-suggestions="querySearchAsync" + value-key="name" + :disabled="!isOperate" + size="mini" + @select=" + (val) => { + handleSelectClient(val, item.prop, scope.row) + } + " + ></el-autocomplete> + + <div + v-if="scope.row[item.prop] && scope.row[item.prop].length > 0 && isOperate" + class="common-select-btn" + @click="handleEditClient(scope, item.prop)" + > + <i class="el-icon-edit" title="缂栬緫"></i> + </div> + <div + v-if="scope.row[item.prop] && scope.row[item.prop].length > 0 && isOperate" + class="common-select-btn" + @click="clearupClient(scope)" + > + <i class="el-icon-remove-outline" title="娓呴櫎"></i> + </div> + <div class="common-select-btn" v-else @click="selClientClick(scope, item.prop)"> + <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i> + </div> </div> - <div v-if="!item.disabled" class="common-select-btn" @click="clearupClient(scope.row, scope)"> - <i class="el-icon-remove-outline" title="娓呴櫎"></i> - </div> - <div class="common-select-btn" v-if="scope.$index != 0 || !item.disabled" - @click="deleteClient(scope.row, scope)"> - <i class="el-icon-delete" title="鍒犻櫎"></i> - </div> - </div> - </el-form-item> - <el-form-item v-else-if="item.date" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop" - :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]"> - <!-- <el-input v-model.trim="scope.row[item.prop]" maxlength="50" size="mini"></el-input> --> - <el-date-picker v-model="scope.row[item.prop]" type="date" size="mini" style="width: 110px"> - </el-date-picker> - </el-form-item> - <el-form-item v-else-if="item.inputNumber" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop" - :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]"> - <el-input-number :disabled="item.disabled" v-model="scope.row[item.prop]" placeholder="" :min="0" - :controls="false" size="mini" style="width: 100%; margin-right: 5px" @change="(val) => { - commonInputChange(val, item.prop, scope.row) - } - "></el-input-number> - </el-form-item> - <el-form-item v-else-if="item.inputFloat" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop" - :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]"> - <!-- 閲囪喘绠$悊 --> - <template v-if="item.multiply"> - <el-input-number :disabled="item.disabled" - :value="scope.row[showSummary.multiply[0]] * scope.row[showSummary.multiply[1]]" placeholder="" :min="0" - :precision="2" :controls="false" size="mini" style="width: 100%; margin-right: 5px" @input="(val) => { - commonInputChange(val, item.prop, scope.row) + </el-form-item> + <el-form-item + v-else-if="item.date" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]" + > + <!-- <el-input v-model.trim="scope.row[item.prop]" maxlength="50" size="mini"></el-input> --> + <el-date-picker + :disabled="!isOperate" + v-model="scope.row[item.prop]" + type="date" + size="mini" + style="width: 110px" + > + </el-date-picker> + </el-form-item> + <el-form-item + v-else-if="item.inputNumber" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]" + > + <el-input-number + v-model="scope.row[item.prop]" + placeholder="" + :min="0" + :controls="false" + :disabled="!isOperate" + size="mini" + style="width: 100%; margin-right: 5px" + @change=" + (val) => { + commonInputChange(val, item.prop, scope.row, scope) + } + " + ></el-input-number> + </el-form-item> + <el-form-item + v-else-if="item.inputFloat" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]" + > + <el-input-number + v-model="scope.row[item.prop]" + placeholder="" + :min="0" + :precision="2" + :disabled="!isOperate" + :controls="false" + size="mini" + style="width: 100%; margin-right: 5px" + @change=" + (val) => { + commonInputChange(val, item.prop, scope.row, scope) + } + " + ></el-input-number> + </el-form-item> + <span v-else> + <template> + {{ scope.row[item.prop] }} + </template> + </span> + </template> + <el-form-item + v-else-if="item.inputNumber && selectBox" + label=" " + :prop="'tableData.' + scope.$index + '.' + item.prop" + :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]" + > + <el-input-number + v-model="scope.row[item.prop]" + placeholder="" + :min="0" + :controls="false" + :disabled="!isOperate" + size="mini" + style="width: 100%; margin-right: 5px" + @change=" + (val) => { + commonInputChange(val, item.prop, scope.row, scope) } - "></el-input-number> - </template> - <template v-else> - <el-input-number :disabled="item.disabled" v-model="scope.row[item.prop]" placeholder="" :min="0" - :precision="2" :controls="false" size="mini" style="width: 100%; margin-right: 5px" @change="(val) => { - commonInputChange(val, item.prop, scope.row) - } - "></el-input-number> - </template> + " + ></el-input-number> </el-form-item> - <span v-else>{{ scope.row[item.prop] }}</span> - <!-- </template> --> - <!-- <span v-else>{{ scope.row[item.prop] }}</span> --> + <span v-else style="text-align: right">{{ scope.row[item.prop] }}</span> </template> </el-table-column> + <el-table-column label="鎿嶄綔" width="40" v-if="!detailEnter" align="center"> + <template slot-scope="scope"> + <el-button type="text" size="small" :disabled="!isOperate" @click="deleteClick(scope)">鍒犻櫎</el-button> + </template> + </el-table-column> + <slot name="tableButton" /> </el-table> </el-form> <div v-if="!detailEnter" style="margin: 10px"> - <el-button :disabled="tableList.disabled" size="small" type="primary" @click="add">鏂板</el-button> - <el-button :disabled="tableList.disabled" size="small" type="primary" @click="empty">娓呯┖</el-button> + <el-button size="small" type="primary" :disabled="!isOperate" @click="add">鏂板</el-button> + <!-- <el-button size="small" type="primary" disabled>瀵煎叆鏄庣粏</el-button> --> + <el-button size="small" type="primary" :disabled="!isOperate" @click="empty">娓呯┖</el-button> </div> - <!-- 浜у搧鍚嶇О --> - <SelectCommonDialog v-if="editSelCommonConfig.editVisible" :edit-common-config="editSelCommonConfig" :sign="sign" - @selClient="selClient" /> + <div v-if="false && (showSummary.total || showSummary.refundable)" style="height: 42px; line-height: 42px"> + <el-row :gutter="10"> + <el-col v-if="showSummary.total" :span="3" :offset="21"> + <span style="font-weight: bold">鍚堣</span> + <span style="margin-left: 10px">{{ total }}</span> + </el-col> + <el-col v-if="showSummary.refundable" :span="3" :offset="21"> + <span style="font-weight: bold">搴旈��娆�</span> + <span style="margin-left: 10px">0.00</span> + </el-col> + </el-row> + </div> + <!-- 鍚堝悓璁㈠崟 --> + <SelectCommonDialog + v-if="editSelCommonConfig.editVisible" + :edit-common-config="editSelCommonConfig" + :sign="sign" + :selectBoxList="tableList.tableData" + :quotationNumber="quotationNumber" + @selClient="selClient" + @getSelectArray="getSelectArray" + /> </div> </template> @@ -113,13 +229,36 @@ type: String, default: "" }, + selectBox: { + type: Boolean, + default: false + }, + // 閭d釜椤甸潰 鐢ㄦ潵鍒ゆ柇璁$畻鏂瑰紡 + pageName: { + type: String, + default: "" + }, + // 鍒楄〃鏂板鏄惁澶氶�� + addTypeIdMultiple: { + type: Boolean, + default: false + }, + // 鏍规嵁鎶ヤ环鍗曟煡璇骇鍝� + quotationNumber: { + type: [String, Number], + default: "" + }, + // 鏄惁鍙互鎿嶄綔 娣诲姞绛� + isOperate: { + type: Boolean, + default: true + }, productTableList: { type: Object, default: () => { return { - tableProductList: [], - disabled: false, tableData: [], // 鎺ュ彛杩斿洖鏁版嵁 + isReturn: false, tableColumn: [ // table琛ㄥ崟 { label: "", prop: "", min: 200, tooltip: true } @@ -135,15 +274,9 @@ total: false, refundable: false, sumProp: [], - multiply: [], - titleProp: ["#", "浜у搧鍚嶇О"], mergeNumber: 1 } } - }, - recalculateShow: { - type: [Boolean], - defalut: true } }, data() { @@ -153,27 +286,31 @@ tableList: [], editSelCommonConfig: { editVisible: false, + isSelectBox: false, title: "", infomation: {} }, - productIndex: 0, - tableProductLists: [], + productIndex: 0 } }, created() { - this.getProductList() - this.tableList = this.productTableList + if (!this.selectBox) { + this.getProductList() + } + this.getTableInfo() + }, + watch: { + productTableList: { + handler() { + this.getTableInfo() + }, + immediate: true + } }, computed: {}, - watch: { - productTableList() { - this.tableList = this.productTableList - }, - }, methods: { - // 閫夋嫨琛� - rowClick(row){ - this.$emit("rowClick",row) + getTableInfo() { + this.tableList = this.productTableList }, // 浜у搧鍚嶇О async getProductList() { @@ -193,6 +330,7 @@ handleReserve(row) { return row._id ? row._id : row.id }, + // 澶氶�� handleSelectionChange(val) { this.$emit("getSelectArray", val) }, @@ -222,9 +360,13 @@ sums[index] = "灏忚:" return } - const title = this.showSummary.titleProp + const title = ["#", "浜у搧鍚嶇О", "浜у搧缂栧彿", "鍗曚綅", "閿�鍞崟浠�", "鎴愭湰鍗曚环"] // 鍘婚櫎鏌愪簺涓嶉渶瑕佽绠楃殑鏁版嵁 if (title.includes(column.label)) { + sums[index] = "" + return + } + if (this.pageName == "quotation" && column.label == "姣涘埄") { sums[index] = "" return } @@ -251,7 +393,6 @@ }) return sums }, - // 鏁板瓧鎹㈣涓洪噾棰濇樉绀烘牸寮� number_format(number, decimals, dec_point, thousands_sep) { decimals = 2 //杩欓噷榛樿璁剧疆淇濈暀涓や綅灏忔暟锛屼篃鍙互娉ㄩ噴杩欏彞閲囩敤浼犲叆鐨勫弬鏁� @@ -282,18 +423,61 @@ }, // 鏂板 add() { - this.$emit("addProductClick") + if (this.addTypeIdMultiple) { + this.productIndex = this.tableList.tableData.length + this.editSelCommonConfig.title = "浜у搧鍚嶇О" + this.editSelCommonConfig.isSelectBox = true + this.editSelCommonConfig.editVisible = true + } else { + this.$emit("addProductClick") + } }, - commonInputChange(val, prop, row) { - this.$emit("inputContent", val, prop, row) + commonInputChange(val, prop, row, scope) { + if (prop === "amount") { + this.tableList.tableData.map((ite) => { + if (ite.name === row.name) { + ite.total = row.amount * row.purchasePrice + } + }) + } + if (this.pageName == "quotation" && prop == "cost" && scope.row.cost) { + let value = scope.row.cost + let reg2 = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/ + if (!reg2.test(value) || value == 0) { + this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒") + return true + } + this.$forceUpdate() + } + if (this.pageName == "quotation") { + if (prop == "purchasePrice" || prop == "cost") { + if (scope.row.purchasePrice && scope.row.cost) { + let profit = Number(scope.row.purchasePrice) - Number(scope.row.cost) + scope.row.profit = profit + "" + let margin = ( + ((Number(scope.row.purchasePrice) - Number(scope.row.cost)) * 100) / + Number(scope.row.cost) + ).toFixed(2) + scope.row.margin = margin + "" + } + } + } + this.$emit("inputContent", val, prop, row, scope) }, // 娓呯┖ empty() { this.$emit("emptyProductClick") }, + // 鍒犻櫎 + deleteClick(scope) { + this.tableList.tableData.splice(scope.$index, 1) + this.$forceUpdate() + this.$message.success("鍒犻櫎鎴愬姛锛�") + this.$emit("deleteClick", scope) + }, // 閫夋嫨浜у搧鍚嶇О鐩稿叧鏂规硶 querySearchAsync(queryString, cb) { - var restaurants = this.tableProductLists + var restaurants = this.productList var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants cb(results) }, @@ -303,98 +487,82 @@ } }, handleSelectClient(item, prop, row) { + // this.clientId = item.id + console.log(item, prop, row) this.tableList.tableData.map((ite) => { if (ite.name === item.name) { - ite.id = row.id ite.amount = item.amount || 1 ite.number = item.number ite.purchasePrice = item.purchasePrice + ite.price = item.purchasePrice + ite.total = item.amount ? item.amount * item.purchasePrice : 1 * item.purchasePrice ite.unit = item.unit ite.deliveryTime = item.deliveryTime ite.shippingDuration = item.shippingDuration ite.modelNumber = item.modelNumber } }) - if (this.detailEnter) { - this.setEditName(item, row.id) - } - this.$emit("handleProduct",item,row) }, - setEditName(item, id) { - let selRow = { - id: id, - deliveryTime: item.deliveryTime, - maximumStock: item.maximumStock, - minimumStock: item.minimumStock, - modelNumber: item.modelNumber, - name: item.name, - number: item.number, - productType: item.productType, - purchasePrice: item.purchasePrice, - remark: item.remark, - shippingDuration: item.shippingDuration, - specifications: item.specifications, - supplierId: item.supplierId, - unit: item.unit - } - this.$emit("selCommonName", selRow) - }, - selClientClick(row, prop, scope) { - console.log(row, prop) + // 鏂板 + selClientClick(scope, prop) { + console.log(scope, prop) this.productIndex = scope.$index this.editSelCommonConfig.title = "浜у搧鍚嶇О" + this.editSelCommonConfig.isSelectBox = true + this.editSelCommonConfig.editVisible = true + }, + // 缂栬緫 + handleEditClient(scope, prop) { + console.log(scope, prop) + this.productIndex = scope.$index + this.editSelCommonConfig.title = "浜у搧鍚嶇О" + this.editSelCommonConfig.isSelectBox = false this.editSelCommonConfig.editVisible = true }, selClient(item) { - console.log(item) - console.log(this.tableList.tableData) - if (this.detailEnter) { - this.tableList.tableData.map((ite) => { - ite.id - ite.name = item.name - ite.amount = item.amount || 1 - ite.number = item.number - ite.purchasePrice = item.purchasePrice - ite.unit = item.unit - ite.deliveryTime = item.deliveryTime - ite.shippingDuration = item.shippingDuration - }) - this.setEditName(item, this.tableList.tableData[0].id) - } else { + let list = this.tableList.tableData.map((item) => item.number) + if (list.findIndex((v) => v == item.number) == -1) { + // this.editConfig.infomation.client_name = row.name this.tableList.tableData.map((ite, index) => { if (index === this.productIndex) { ite.name = item.name ite.productId = item.id - ite.productIndex = this.productIndex+1 ite.amount = item.amount || 1 ite.number = item.number ite.purchasePrice = item.purchasePrice + ite.price = item.purchasePrice + ite.total = item.amount ? item.amount * item.purchasePrice : 1 * item.purchasePrice ite.unit = item.unit ite.deliveryTime = item.deliveryTime ite.shippingDuration = item.shippingDuration - this.$set(this.tableList.tableData, index, ite) - this.$forceUpdate() + // this.$set(this.tableList.tableData, index, ite) + // this.$forceUpdate() } }) - console.log(this.tableList.tableData, "=====chanp") + } else { + this.$message.error("涓嶈兘閫夋嫨閲嶅鐨勪骇鍝侊紝 璇烽噸鏂伴�夋嫨") } }, + getSelectArray(val) { + let list = val.map((item) => { + let productId = item.id + this.$delete(item, "id") + return { + ...item, + productId: productId, + amount: 1, + price: item.purchasePrice, + total: 1 * item.purchasePrice + } + }) + this.$emit("getSelectArray", list, this.productIndex) + }, // 娓呴櫎宸查�夋嫨鐢ㄦ埛 - clearupClient(row, scope) { + clearupClient(scope) { this.productIndex = scope.$index this.tableList.tableData.map((ite, index) => { - console.log(scope.$index) - if (scope.$index && scope.$index >= 0) { - if (index === this.productIndex) { - ite.name = "" - ite.amount = 1 - ite.number = "" - ite.purchasePrice = 0 - ite.unit = "" - ite.deliveryTime = 0 - ite.shippingDuration = 0 - } - } else { + if (index === this.productIndex) { + ite.productId = "" ite.name = "" ite.amount = 1 ite.number = "" @@ -405,14 +573,18 @@ } }) this.$emit("clearupProduct", this.tableList.tableData) - }, - deleteClient(row, scope) { - if (this.tableList.tableData.length == 1) { - this.$message.error("鑷冲皯淇濈暀涓�鏉★紝涓嶈兘鍒櫎浜嗭紒") - return true - } - this.tableList.tableData.splice(scope.$index, 1) } + // 澶氶�夎缃凡閫変腑 + // toggleSelection(rows) { + // console.log("88888888888888888888888888888888888888888") + // console.log(rows) + // if (rows) { + // rows.forEach((row) => { + // this.$refs.fromTable.toggleRowSelection(row, true) + // console.log(row) + // }) + // } + // } } } </script> @@ -420,14 +592,10 @@ <!-- Add "scoped" attribute to limit CSS to this component only --> <style lang="scss" scoped> .page-view { - min-width: 100px; - .el-form-item { margin-bottom: 0; - .custom-name { display: flex; - .common-select-btn { margin-left: 5px; font-size: 18px; @@ -436,29 +604,25 @@ } } } - ::v-deep { .el-form-item__label { display: none; } - .el-table__footer-wrapper tbody td.el-table__cell { background-color: #fff; // text-align: right; font-weight: bold; } - .el-input--suffix .el-input__inner { padding-right: 0px; } - .el-table .cell, - .el-table th.el-table__cell>.cell { + .el-table th.el-table__cell > .cell { padding: 0 5px; } - .el-input__inner { - text-align: left; + // text-align: left; + text-align: center !important; } } </style> diff --git a/src/components/makepager/TableCommonView.vue b/src/components/makepager/TableCommonView.vue index 42f2469..50ac390 100644 --- a/src/components/makepager/TableCommonView.vue +++ b/src/components/makepager/TableCommonView.vue @@ -1,109 +1,140 @@ +<!-- eslint-disable vue/no-use-v-if-with-v-for --> <template> - <div class="table-view"> + <div class="table-view" v-loading="loading"> <el-table ref="table" border :data="tableList.tableInfomation" tooltip-effect="dark" - style="width: 100%" :height="'calc(100% - 0px)'" :max-height="tableList.maxHeight" + style="width: 100%" :lazy="tableList.lazy" - size="mini" + :show-summary="showSummary.show" + :summary-method="getSummaries" + :span-method="arraySpanMethod" @selection-change="handleSelectionChange" - :header-cell-style="{ background: '#f1f3f8', color: '#000009', 'font-size': '14px' }" - :highlight-current-row="tableList.highlight" - :row-class-name="tableRowClassName" + :header-cell-style="{ background: '#f1f3f8', color: '#000009', 'font-size': '12px', 'font-family': 'PingFangSC' }" + size="mini" @row-click="tableRowClick" - :row-key="tableList.key" - :default-expand-all="tableList.isDefaultExpandAll" - :tree-props="{ children: 'child', hasChildren: 'hasChildren' }" + :row-class-name="tableRowClassName" > - <el-table-column align="center" v-if="tableList.selectBox" type="selection" width="40"> </el-table-column> - <el-table-column align="center" v-if="tableList.selectIndex" type="index" label="搴忓彿" width="50"> - </el-table-column> - <template v-for="(item, i) in tableList.tableColumn"> - <el-table-column - align="center" - :key="i" - :prop="item.prop" - :label="item.label" - :width="item.width" - :min-width="item.min" - show-overflow-tooltip - :sortable="item.sortable" - v-if="item.isShowColumn" - > - <template slot-scope="scope"> - <span v-if="item.price">{{ "锟�" + number_format(scope.row[item.prop], 2, ".", ",") }}</span> - <div v-else-if="item.status" :class="scope.row.status">{{ scope.row[item.prop] }}</div> - <span v-else-if="item.isTime">{{ - dateFormat("YYYY-mm-dd HH:MM:SS", scope.row[item.prop]) === "1900-01-01 00:06:26" - ? "--" - : dateFormat("YYYY-mm-dd HH:MM:SS", scope.row[item.prop]) + <el-table-column v-if="selectBox" type="selection" width="40" :selectable="selectable"> </el-table-column> + <el-table-column v-if="tableList.selectIndex" type="index" label="搴忓彿" width="50"></el-table-column> + <el-table-column + v-for="(item, i) in tableList.tableColumn" + :key="i" + :prop="item.prop" + :label="item.label" + :width="item.width" + :min-width="item.min" + show-overflow-tooltip + :sortable="item.sortable" + v-if="item.isShowColumn" + > + <template slot-scope="scope"> + <span v-if="item.price">{{ "锟�" + number_format(scope.row[item.prop], 2, ".", ",") }}</span> + <div v-else-if="item.status" :class="scope.row.status">{{ scope.row[item.prop] }}</div> + <span v-else-if="item.isTime">{{ + dateFormat("YYYY-mm-dd HH:MM:SS", scope.row[item.prop]) === "1900-01-01 00:06:26" + ? "--" + : dateFormat("YYYY-mm-dd HH:MM:SS", scope.row[item.prop]) + }}</span> + <span v-else-if="item.isClick && scope.row[item.prop]" class="sel-name" @click="selNameClick(scope.row)">{{ + scope.row[item.prop] + }}</span> + <span v-else-if="item.isFirst">{{ scope.row[item.prop] ? "鏄�" : "鍚�" }}</span> + <span + v-else-if="item.isSalesLeadClick && scope.row[item.prop]" + class="sel-name" + @click="selSalesLeadClick(scope.row)" + >{{ scope.row[item.prop] }}</span + > + <span + v-else-if="item.isClientClick && scope.row[item.prop]" + class="sel-name" + @click="selClientClick(scope.row)" + >{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span + > + <span + v-else-if="item.isContactClick && scope.row[item.prop]" + class="sel-name" + @click="selContactsClick(scope.row)" + >{{ scope.row[item.prop] }}</span + > + <span + v-else-if="item.isMasterClick && scope.row[item.prop]" + class="sel-name" + @click="selMasterClick(scope.row)" + >{{ scope.row[item.prop] }}</span + > + <span + v-else-if="item.isServiceOrder && scope.row[item.prop]" + class="sel-name" + @click="selServiceOrderClick(scope.row)" + >{{ scope.row[item.prop] }}</span + > + <span + v-else-if="item.isCommonClick && scope.row[item.prop]" + class="sel-name" + @click="selCommonClick(scope.row)" + >{{ scope.row[item.prop] }}</span + > + <div v-else-if="item.isProductName" class="product-view"> + <ul v-if="scope.row.products && scope.row.products.length > 0"> + <li v-for="(item, index) in scope.row.products" :key="index"> + <div class="name-view"> + {{ item.name }} + </div> + </li> + </ul> + <div v-else class="no-product">{{ "--" }}</div> + </div> + <div v-else-if="item.isProductAmount" class="product-view"> + <ul v-if="scope.row.products && scope.row.products.length > 0"> + <li v-for="(item, index) in scope.row.products" :key="index"> + <div class="name-view"> + {{ item.amount }} + </div> + </li> + </ul> + <div v-else class="no-product">{{ "--" }}</div> + </div> + <div v-else-if="item.isProductPrice" class="product-view"> + <ul v-if="scope.row.products && scope.row.products.length > 0"> + <li v-for="(item, index) in scope.row.products" :key="index"> + <div class="name-view"> + {{ item.price }} + </div> + </li> + </ul> + <div v-else class="no-product">{{ "--" }}</div> + </div> + <div v-else-if="item.isProductTotal" class="product-view"> + <ul v-if="scope.row.products && scope.row.products.length > 0"> + <li v-for="(item, index) in scope.row.products" :key="index"> + <div class="name-view"> + {{ item.total }} + </div> + </li> + </ul> + <div v-else class="no-product">{{ "--" }}</div> + </div> + <!-- 璋冪敤鏂规硶鏄剧ず鏂囧瓧 --> + <div v-else-if="item.isCallMethod"> + <span :class="item.isClass ? item.getClassName(scope.row[item.prop], scope.row) : ''">{{ + item.getCallMethod(scope.row[item.prop], scope.row) }}</span> - <span - v-else-if="item.isClick && scope.row[item.prop]" - class="sel-name" - @click="selCommonClick(scope.row)" - >{{ scope.row[item.prop] }}</span - > - <span v-else-if="item.isFirst">{{ scope.row[item.prop] ? "鏄�" : "鍚�" }}</span> - <span - v-else-if="item.isCommonClick && scope.row[item.prop]" - class="sel-name" - @click="selCommonClick(scope.row)" - >{{ scope.row[item.prop] }}</span - > - <div v-else-if="item.isProductName" class="product-view"> - <ul v-if="scope.row.products && scope.row.products.length > 0"> - <li v-for="(item, index) in scope.row.products" :key="index"> - <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'"> - {{ item.name }} - </div> - </li> - </ul> - <div v-else class="no-product">{{ "--" }}</div> - </div> - <div v-else-if="item.isProductAmount" class="product-view"> - <ul v-if="scope.row.products && scope.row.products.length > 0"> - <li v-for="(item, index) in scope.row.products" :key="index"> - <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'"> - {{ item.amount }} - </div> - </li> - </ul> - <div v-else class="no-product">{{ "--" }}</div> - </div> - <div v-else-if="item.isProductPrice" class="product-view"> - <ul v-if="scope.row.products && scope.row.products.length > 0"> - <li v-for="(item, index) in scope.row.products" :key="index"> - <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'"> - {{ item.price }} - </div> - </li> - </ul> - <div v-else class="no-product">{{ "--" }}</div> - </div> - <div v-else-if="item.isProductTotal" class="product-view"> - <ul v-if="scope.row.products && scope.row.products.length > 0"> - <li v-for="(item, index) in scope.row.products" :key="index"> - <div :class="scope.row.products.length === 1 ? 'name-view no-bottom' : 'name-view'"> - {{ item.total }} - </div> - </li> - </ul> - <div v-else class="no-product">{{ "--" }}</div> - </div> - <span v-else>{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span> - </template> - </el-table-column> - </template> + </div> + <span v-else>{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span> + </template> + </el-table-column> <slot name="tableButton" /> <div slot="empty"> <el-empty description="鏆傛棤鏁版嵁"></el-empty> </div> </el-table> + <div class="overSpread1" v-show="iscolopen" @click="onMaskClick"></div> <div class="styleBtn"> <i @click="checkCol()" class="label">...</i> @@ -118,16 +149,18 @@ export default { name: "TableCommonView", props: { + selectBox: { + type: Boolean, + default: false + }, tableList: { type: Object, default: () => { return { - selectBox: false, - selectIndex: false, + selectIndex: true, tableInfomation: [], // 鎺ュ彛杩斿洖鏁版嵁 showcol: [], allcol: [], - highlight: false, tableColumn: [ // table琛ㄥ崟 { label: "", prop: "", min: 200, tooltip: true } @@ -141,8 +174,7 @@ return { show: false, sumProp: [], - mergeNumber: 1, - totalName: "鏈〉鎬昏" + mergeNumber: 1 } } }, @@ -152,14 +184,24 @@ default: () => { return {} } + }, + loading: { + type: Boolean, + default: false + }, + selectBoxList: { + type: Array, + default: () => [] } }, + data() { return { iscolopen: false, showcol: [] } }, + computed: {}, watch: { "tableList.showcol": { handler(newVal) { @@ -168,7 +210,6 @@ immediate: true } }, - computed: {}, methods: { onMaskClick() { this.iscolopen = false @@ -195,10 +236,16 @@ .querySelector(".el-table__footer") var cell = current.rows[0].cells for (let i = 0; i < this.showSummary.mergeNumber; i++) { - cell[i].style.display = "none" + cell[i] && cell[i].style && (cell[i].style.display = "none") } - cell[this.showSummary.mergeNumber].classList.remove("is-left") - cell[this.showSummary.mergeNumber].colSpan = this.showSummary.mergeNumber.toString() + if (cell[this.showSummary.mergeNumber]) { + if (cell[this.showSummary.mergeNumber].classList) { + cell[this.showSummary.mergeNumber].classList.remove("is-left") + } + if (cell[this.showSummary.mergeNumber].colSpan) { + cell[this.showSummary.mergeNumber].colSpan = this.showSummary.mergeNumber.toString() + } + } } }) } @@ -210,7 +257,7 @@ const sums = [] columns.forEach((column, index) => { if (index === this.showSummary.mergeNumber) { - sums[index] = this.showSummary.totalName + sums[index] = "鏈〉鎬昏" } const values = data.map((item) => Number(item[column.property])) if (this.showSummary.sumProp.includes(column.property)) { @@ -309,7 +356,31 @@ } return fmt }, - // 鍏叡璇︽儏 + // 鏂板缓缂栬緫閫夋嫨寮圭獥 + selNameClick(row) { + this.$emit("selCommonClick", row) + }, + // 閿�鍞嚎绱� + selSalesLeadClick(row) { + this.$emit("selSalesLeadClick", row) + }, + // 瀹㈡埛鍚嶇О + selClientClick(row) { + this.$emit("selClientClick", row) + }, + // 鑱旂郴浜哄鍚� + selContactsClick(row) { + this.$emit("selContactsClick", row) + }, + // 閿�鍞�诲崟 + selMasterClick(row) { + this.$emit("selMasterClick", row) + }, + // 瀹㈡埛鏈嶅姟鍗� + selServiceOrderClick(row) { + this.$emit("selServiceOrderClick", row) + }, + // 鍏叡锛堥攢鍞満浼氥�佹姤浠峰崟銆侀攢鍞�诲崟銆侀攢鍞瓙鍗曘�傘�傘�傦級 selCommonClick(row) { this.$emit("selCommonClick", row) }, @@ -325,6 +396,14 @@ } } this.$emit("tableRowClassName", row) + }, + selectable(row) { + let list = this.selectBoxList.map((item) => item.number) + if (list.findIndex((v) => v == row.number) == -1) { + return true + } else { + return false + } } } } @@ -333,9 +412,6 @@ <!-- Add "scoped" attribute to limit CSS to this component only --> <style lang="scss" scoped> .table-view { - // margin-top: 20px; - // margin-right: 10px; - // margin-bottom: 40px; position: relative; height: 100%; .blue { @@ -354,19 +430,22 @@ margin-left: -10px; margin-right: -11px; li { - height: 57px; - line-height: 57px; + height: 22px; + line-height: 22px; .name-view { padding-left: 10px; border-bottom: 1px solid #ebeef5; } .no-bottom { - border-bottom: 0px; + border-bottom: 0; } } + li:last-child .name-view { + border-bottom: none; + } .no-product { - height: 57px; - line-height: 57px; + height: 22px; + line-height: 22px; } } } @@ -400,9 +479,12 @@ .el-table .cell .el-button--text.el-button--small { padding: 4px 0; } - .el-table .onSelect { - background: #ebf2ff; - } +} + +::v-deep .el-table .el-table__cell { + padding: 6px 0 !important; + height: 35px; + text-align: center; } .overSpread1 { @@ -422,8 +504,8 @@ // line-height: 26px; // background: #06c062; top: 0; - right: 2px; - z-index: 9999; + right: -6px; + z-index: 11; .label { position: absolute; top: 6px; @@ -435,7 +517,7 @@ } .checkbox-group { width: 160px; - height: 330px; + height: 300px; overflow: auto; display: flex; flex-direction: column; diff --git a/src/views/other/commonDialog/SelectCommonDialog.vue b/src/views/other/commonDialog/SelectCommonDialog.vue index e4d3bc0..74d664a 100644 --- a/src/views/other/commonDialog/SelectCommonDialog.vue +++ b/src/views/other/commonDialog/SelectCommonDialog.vue @@ -28,12 +28,15 @@ <el-button type="primary" size="mini" disabled>蹇�熷垱寤�</el-button> --> </div> </div> - <TableCommonView + <TableCommonView + class="bg-list" ref="tableListRef" :table-list="tableList" - :select-box="false" + :select-box="editCommonConfig.isSelectBox" + :selectBoxList="selectBoxList" @selCommonClick="selNameClick" @selTableCol="selTableCol" + @getSelectArray="getSelectArray" > </TableCommonView> <div slot="footer" class="dialog-footer"> @@ -42,6 +45,10 @@ <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" /> </div> </div> + </div> + <div slot="footer" class="dialog-footer" v-if="editCommonConfig.isSelectBox"> + <el-button type="primary" size="small" @click="saveClick()">纭畾</el-button> + <el-button size="small" @click="editConfig.editVisible = false">鍙栨秷</el-button> </div> </el-dialog> </div> @@ -60,7 +67,11 @@ default: () => { return { editVisible: false, + isSelectBox: false, title: "", + clientId: 0, + isRequest: true, + client_name: "", tableInfomation: [] } } @@ -68,6 +79,10 @@ sign: { type: String, default: "" + }, + selectBoxList: { + type: Array, + default: () => [] } }, components: {}, @@ -87,13 +102,18 @@ searchSel: {}, keyword: "", keywordType: "", - showProductCol: ["浜у搧鍚嶇О", "浜у搧缂栧彿"], + showProductCol: ["浜у搧鍚嶇О", "浜у搧缂栧彿", "閿�鍞崟浠�", "鍗曚綅", "浜у搧瑙勬牸", "鍨嬪彿"], tableProductColumn: [ { label: "浜у搧鍚嶇О", prop: "name", isClick: true }, - { label: "浜у搧缂栧彿", prop: "number" } + { label: "浜у搧缂栧彿", prop: "number" }, + { label: "閿�鍞崟浠�", prop: "purchasePrice" }, + { label: "鍗曚綅", prop: "unit" }, + { label: "浜у搧瑙勬牸", prop: "specifications" }, + { label: "鍨嬪彿", prop: "modelNumber" } ], showCol: [], - tableColumn: [] + tableColumn: [], + selectArray: [] } }, created() { @@ -133,17 +153,17 @@ } }, selTableCol(val) { - this.showcol = val; - this.tableList.tableColumn = this.setColumnVisible(val); + this.showcol = val + this.tableList.tableColumn = this.setColumnVisible(val) }, - // setColumnVisible(showCol){ - // return this.tableColumn.map(ele=>{ - // return { - // ...ele, - // isShowColumn:showCol.includes(ele.label) - // } - // }) - // }, + // 鍒楄〃澶氶�� + getSelectArray(val) { + this.selectArray = val + }, + saveClick() { + this.$emit("getSelectArray", this.selectArray) + this.editConfig.editVisible = false + }, // 璇锋眰鏁版嵁 async getData() { this.loading = true @@ -155,7 +175,7 @@ async getProductList() { let fn = this.sign == "purchase" ? getProductList : getProductListFromGrpc await fn({ - keyword:this.keyword, + keyword: this.keyword, page: this.pagerOptions.currPage, pageSize: this.pagerOptions.pageSize }).then((res) => { @@ -186,7 +206,7 @@ }, // 鎼滅储 searchClick(content) { - console.log( content) + console.log(content) this.keyword = content this.getData() }, diff --git a/src/views/purchaseManage/purchase/components/AddPurchase.vue b/src/views/purchaseManage/purchase/components/AddPurchase.vue index 35aeba2..ed08a9b 100644 --- a/src/views/purchaseManage/purchase/components/AddPurchase.vue +++ b/src/views/purchaseManage/purchase/components/AddPurchase.vue @@ -97,11 +97,11 @@ </div> </el-form-item> </el-col> - <el-col :span="12"> + <!-- <el-col :span="12"> <el-form-item label="鍗曟嵁鏉ユ簮" prop="orderSource"> <el-input v-model="editConfig.infomation.orderSource" disabled placeholder="璇峰~鍐�"></el-input> </el-form-item> - </el-col> + </el-col> --> <el-col :span="12"> <el-form-item label="閲囪喘鍗曞悕绉�" prop="name"> <el-input @@ -164,6 +164,54 @@ </el-date-picker> </el-form-item> </el-col> + <el-col :span="12"> + <el-form-item label="鏀惰揣浠撳簱" prop="warehouse"> + <el-select + placeholder="璇烽�夋嫨鏀惰揣浠撳簱" + v-model="editConfig.infomation.warehouse" + clearable + style="width: calc(100% - 0px)" + :disabled="editConfig.isDisabled" + > + <el-option + v-for="(ele, index) in receiveWhouseList" + :key="index" + :label="ele.name" + :value="ele.name" + ></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鍦板潃" prop="warehouseAddress"> + <el-input + :disabled="editConfig.isDisabled" + v-model="editConfig.infomation.warehouseAddress" + placeholder="璇峰~鍐�" + clearable + ></el-input> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鎺ユ敹浜�" prop="principal"> + <el-input + :disabled="editConfig.isDisabled" + v-model="editConfig.infomation.principal" + placeholder="璇峰~鍐�" + clearable + ></el-input> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鏉ユ簮鍗曟嵁" prop="sourceOrder"> + <el-input + :disabled="editConfig.isDisabled" + v-model="editConfig.infomation.sourceOrder" + placeholder="璇峰~鍐�" + clearable + ></el-input> + </el-form-item> + </el-col> <el-col :span="24"> <el-form-item label="澶囨敞淇℃伅" prop="remark"> <el-input @@ -185,11 +233,13 @@ :detailEnter="editCommonConfig.detailEnter" :show-summary="showSummary" :recalculateShow="false" + :addTypeIdMultiple="true" :product-table-list="productTableList" sign="purchase" @inputContent="inputContent" @getSummaries="getSummaries" @addProductClick="addProductClick" + @getSelectArray="getSelectArray" @emptyProductClick="emptyProductClick" @clearupProduct="clearupProduct" @rowClick="rowClick" @@ -289,7 +339,13 @@ import CommonFormTableView from "@/components/makepager/CommonFormTableView" import BomDialog from "@/components/makepager/BomDialog" import { getProductList } from "@/api/productManage/product" -import { addPurchase, updatePurchase, savePurchaseType, getPurchaseType } from "@/api/purchaseManage/purchase" +import { + addPurchase, + updatePurchase, + savePurchaseType, + getPurchaseType, + getWarehouseInfo +} from "@/api/purchaseManage/purchase" import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog" // import { formToJSON } from "axios"; import codeMixin from "@/components/mixin/codeMixin" @@ -316,7 +372,7 @@ editConfig: this.editCommonConfig, rules: { purchaseTypeId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], - supplierName: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], + supplierName: [{ required: true, message: "璇烽�夋嫨渚涘簲鍟嗗悕绉�", trigger: "change" }], phone: [ { required: false, @@ -342,6 +398,7 @@ { validator: this.validatorNumThree, trigger: "change" } ], number: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }], + warehouse: [{ required: true, message: "璇烽�夋嫨鏀惰揣浠撳簱", trigger: "change" }], signingDate: [{ required: true, message: "璇烽�夋嫨绛剧害鏃ユ湡", trigger: "change" }], deliveryDate: [{ required: true, message: "璇烽�夋嫨浜や粯鏃ユ湡", trigger: "change" }], }, @@ -351,7 +408,7 @@ total: false, sumProp: ["price", "total"], multiply: ["amount", "price"], - titleProp: ["缂栧彿", "浜у搧鍚嶇О", "浜у搧缂栧彿", "璁¢噺鍗曚綅", "瑙勬牸鍨嬪彿", "閲囪喘鍗曚环", "鎻忚堪"], + titleProp: ["缂栧彿", "浜у搧鍚嶇О", "浜у搧缂栧彿", "璁¢噺鍗曚綅", "瑙勬牸", "鍨嬪彿", "閲囪喘鍗曚环", "鎻忚堪"], mergeNumber: 4, totalName: "灏忚" }, @@ -384,13 +441,12 @@ return time.getTime() > Date.now() } }, + receiveWhouseList: [] // 鏀惰揣浠撳簱鍒楄〃 } }, created() { - let date= new Date() - this.editConfig.infomation.signingDate=date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate()) - console.log(this.editConfig,"鍙傛暟") this.handleGetBomKindDictList() + this.getWarehouseInfo() this.$store.dispatch("getSupplier") this.formInfo() }, @@ -463,9 +519,6 @@ this.plcBrandList = res.data this.setTableForm() if (val) { - // this.plcBrandList.map((item)=>{ - // item.purchaseTypeId=item.id - // }) for (let i in this.plcBrandList) { if (this.plcBrandList[i][this.editRow.isDefault]) { this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId @@ -576,6 +629,8 @@ if (res.code === 200) { this.$message.success("鍒涘缓鎴愬姛") this.$parent.getData() + } else { + this.$message.error(res.msg) } }) } @@ -667,7 +722,11 @@ realTotalPrice: this.total ? Number(this.total) : 0, totalPrice: this.totalTwo ? Number(this.totalTwo) : 0, status: data.status, - quantity: data.quantity // 閲囪喘鏁伴噺 + quantity: data.quantity, // 閲囪喘鏁伴噺 + warehouse: data.warehouse || "", // 鏀惰揣浠撳簱 + warehouseAddress: data.warehouseAddress || "", // 鏀惰揣浠撳簱鍦板潃 + principal: data.principal || "", // 浠撳簱璐熻矗浜� + sourceOrder: data.sourceOrder || "" // 鏉ユ簮鍗曟嵁 } } if (data.id) { @@ -742,9 +801,9 @@ this.tableData = [ { purchaseId: 0, - productId:Number(this.productId), + productId: Number(this.productId), productIndex: this.productIndex, - amount: 0, + amount: 1, name: "", number: "", price: 0, @@ -769,6 +828,7 @@ supplierId: undefined, tableData: this.tableData, disabled: this.editConfig.isDisabled, + isReturn: true, tableColumn: [ { label: "浜у搧鍚嶇О", @@ -780,11 +840,12 @@ }, { label: "浜у搧缂栧彿", prop: "number", min: 150 }, { label: "璁¢噺鍗曚綅", prop: "unit" }, - { label: "瑙勬牸鍨嬪彿", prop: "specifications" }, + { label: "瑙勬牸", prop: "specifications" }, + { label: "鍨嬪彿", prop: "modelNumber" }, { label: "鏁伴噺", prop: "amount", inputNumber: true, disabled: this.editConfig.isDisabled }, { label: "閲囪喘鍗曚环", - prop: "price", + prop: "purchasePrice", inputFloat: true, isRequird: true, disabled: this.editConfig.isDisabled @@ -797,12 +858,10 @@ }, // 浜у搧鍒楄〃杈撳叆 inputContent(val, prop, row) { - // this.productId = row.productId; - this.productIndex = row.productIndex let num = 0 this.tableData.map((item) => { num += item.amount - if (item.productIndex === row.productIndex) { + if (item.number === row.number) { item[prop] = val } }) @@ -836,18 +895,35 @@ }, // 浜у搧鏂板 addProductClick() { - this.productIndex++ - this.tableData.push({ - productIndex: this.productIndex, - productId: "", - id: 0, - amount: 0, - desc: "", - name: "", - number: "", - price: 0, - total: 0 - }) + // this.productIndex++ + // this.tableData.push({ + // productIndex: this.productIndex, + // productId: "", + // id: 0, + // amount: 0, + // desc: "", + // name: "", + // number: "", + // price: 0, + // total: 0 + // }) + // this.showSummary.show = true + }, + // 鏂板鏂瑰紡淇敼 + getSelectArray(val, index) { + console.log(val, "ddd99999") + if (this.tableData.length == 1 && this.tableData[0].number.length == 0) { + this.tableData = [] + } + if (index < this.tableData.length) { + this.tableData.splice(index, 1) + val.map((item, ind) => { + this.tableData.splice(index + ind, 0, item) + }) + } else { + this.tableData = this.tableData.concat(val) + } + this.productTableList.tableData = this.tableData this.showSummary.show = true }, // 浜у搧娓呯┖ @@ -881,6 +957,13 @@ handleProduct(item) { this.tableData[this.productListIdx].productId = Number(item.id) console.log(item, "閫変腑浜у搧", this.tableData) + }, + // 鑾峰彇鏀惰揣浠撳簱鍒楄〃 + async getWarehouseInfo() { + await getWarehouseInfo().then((res) => { + console.log(res) + this.receiveWhouseList = res.data.info + }) } } } diff --git a/src/views/purchaseManage/purchase/index.vue b/src/views/purchaseManage/purchase/index.vue index 8fd2cb2..2283fa2 100644 --- a/src/views/purchaseManage/purchase/index.vue +++ b/src/views/purchaseManage/purchase/index.vue @@ -16,13 +16,15 @@ </div> <div class="body"> - <div class="body-card"> + <div class="content-top"> <div class="list-view"> <TableCommonView ref="tableListRef" :table-list="tableList" @selCommonClick="selCommonClick" @selTableCol="selTableCol" + @tableRowClick="tableRowClick" + :selectClassRow="selectRow" > <template slot="tableButton"> <el-table-column label="鐘舵��" width="120"> @@ -78,6 +80,41 @@ <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" /> </div> </div> + <div class="content-bottom"> + <div class="bottom-tabs"> + <div + class="tab-pane" + @click="getTab(0)" + :style="{ + background: TabsIndex == 0 ? '#2a78fb' : '#F1F3F8', + color: TabsIndex == 0 ? '#fff' : '#666' + }" + > + 浜у搧淇℃伅 + </div> + <div + class="tab-pane" + @click="getTab(1)" + :style="{ + background: TabsIndex == 1 ? '#2a78fb' : '#F1F3F8', + color: TabsIndex == 1 ? '#fff' : '#666' + }" + > + 鏀惰揣淇℃伅 + </div> + </div> + <div class="list-view"> + <TableCommonView :loading="loading" :table-list="productTableList" @selTableCol="selBottomTableCol"> + <!-- <template slot="tableButton"> + <el-table-column label="鎿嶄綔" width="160" fixed="right"> + <template slot-scope="scope"> + <el-button @click="viewClick(scope.row)" type="text" size="small">鏌ョ湅</el-button> + </template> + </el-table-column> + </template> --> + </TableCommonView> + </div> + </div> </div> <!-- 鏂板缓/缂栬緫閿�鍞嚎绱� --> @@ -91,7 +128,13 @@ <script> import pageMixin from "@/components/makepager/pager/mixin/pageMixin" -import { getPurchaseList, getPurchaseInfo, submitPurchase, deletePurchase } from "@/api/purchaseManage/purchase" +import { + getPurchaseList, + getPurchaseInfo, + submitPurchase, + deletePurchase, + getOperationInfo +} from "@/api/purchaseManage/purchase" import DetailSupplier from "@/views/purchaseManage/purchase/DetailSupplier" import AddPurchase from "@/views/purchaseManage/purchase/components/AddPurchase" import { getSupplierList } from "@/api/supplierManage/supplier" @@ -103,8 +146,33 @@ mixins: [pageMixin], computed: {}, data() { + // 浜у搧淇℃伅 + const productColumn = [ + { label: "浜у搧缂栧彿", prop: "number", default: true }, + { label: "浜у搧鍚嶇О", prop: "name" }, + { label: "瑙勬牸", prop: "specifications" }, + { label: "鍨嬪彿", prop: "modelNumber" }, + { label: "閲囪喘鏁伴噺", prop: "amount" }, + { label: "宸插彂璐ф暟閲�", prop: "sendAmount" }, + { label: "宸插叆搴撴暟閲�", prop: "overAmount" }, + { label: "鍗曚綅", prop: "unit" }, + { label: "閲囪喘鍗曚环", prop: "purchasePrice", price: true }, + { label: "浠风◣鍚堣", prop: "total", price: true } + ] + // 鏀惰揣淇℃伅 + const recriveColumn = [ + { label: "鍏ュ簱鍗曞彿", prop: "operationNumber", default: true }, + { label: "鏀惰揣浠撳簱", prop: "warehouseName" }, + { label: "浜у搧鍚嶇О", prop: "name" }, + { label: "浜у搧缂栫爜", prop: "number" }, + { label: "鏁伴噺", prop: "amount" }, + { label: "鍏ュ簱鏃堕棿", prop: "overTime" }, + { label: "鏀惰揣浜�", prop: "principal" }, + { label: "鐘舵��", prop: "status", isCallMethod: true, getCallMethod: this.getreceiveStatusStatus } + ] return { purchaseStatusList: getDataByType("purchaseStatus"), + receiveStatusList: getDataByType("receiveStatus"), tableLoading: false, tableList: {}, // 鍒楄〃 selValueList: [], @@ -133,7 +201,30 @@ { label: "缁忓姙浜�", prop: "handledBy", min: 130 }, { label: "鍒跺崟浜�", prop: "creator", min: 130 } ], - showCol: ["閲囪喘鍗曞彿", "閲囪喘鍗曞悕绉�", "鍗曟嵁绫诲瀷", "渚涘簲鍟嗗悕绉�", "閲囪喘鏁伴噺", "鏀惰揣浠撳簱", "缁忓姙浜�", "鍒跺崟浜�"] + showCol: ["閲囪喘鍗曞彿", "閲囪喘鍗曞悕绉�", "鍗曟嵁绫诲瀷", "渚涘簲鍟嗗悕绉�", "閲囪喘鏁伴噺", "鏀惰揣浠撳簱", "缁忓姙浜�", "鍒跺崟浜�"], + tableBottomColumn: [], + showBottomCol: [], + TabsIndex: "0", + productTableList: {}, + // 浜у搧淇℃伅 + productColumn: productColumn, + showProductCol: [ + "浜у搧缂栧彿", + "浜у搧鍚嶇О", + "瑙勬牸", + "鍨嬪彿", + "閲囪喘鏁伴噺", + "宸插彂璐ф暟閲�", + "宸插叆搴撴暟閲�", + "鍗曚綅", + "閲囪喘鍗曚环", + "浠风◣鍚堣" + ], + // 鏀惰揣淇℃伅 + recriveColumn: recriveColumn, + showReceiveCol: ["鍏ュ簱鍗曞彿", "鏀惰揣浠撳簱", "浜у搧鍚嶇О", "浜у搧缂栫爜", "鏁伴噺", "鍏ュ簱鏃堕棿", "鏀惰揣浜�", "鐘舵��"], + loading: false, + selectRow: {} } }, created() { @@ -175,8 +266,19 @@ return "--" } }, - setColumnVisible(showCol) { - return this.tableColumn.map((ele) => { + getreceiveStatusStatus(val) { + if (val) { + for (let i in this.receiveStatusList) { + if (this.receiveStatusList[i].id == val) { + return this.receiveStatusList[i].name + } + } + } else { + return "--" + } + }, + setColumnVisible(showCol, tableColumn) { + return tableColumn.map((ele) => { return { ...ele, isShowColumn: showCol.includes(ele.label) @@ -189,9 +291,13 @@ selectIndex: true, showcol: this.showCol, allcol: [], - tableColumn: this.setColumnVisible(this.showCol) + tableColumn: this.setColumnVisible(this.showCol, this.tableColumn) } this.tableList.allcol = this.tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label) + // bottom 浜у搧淇℃伅/鏀惰揣淇℃伅 + this.tableBottomColumn = this.productColumn + this.showBottomCol = this.showProductCol + this.setBottomList() }, selTableCol(val) { this.showcol = val @@ -212,6 +318,10 @@ }) this.tableList.tableInfomation = list || [] this.pagerOptions.totalCount = res.data.total + if (res.data.total > 0) { + this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {} + this.tableRowClick(this.selectRow) + } } }) .catch((err) => { @@ -255,7 +365,7 @@ number: "", contact: "", phone: "", - signingDate: "", + signingDate: this.getCurrentDate(), deliveryDate: "", remark: "", wholeDiscountType: null, @@ -265,7 +375,14 @@ realTotalPrice: 0 } }, - + // 鑾峰彇褰撳墠鏃ユ湡 + getCurrentDate() { + let now = new Date() + let year = now.getFullYear() + let month = now.getMonth() + 1 + let day = now.getDate() + return year + "-" + month + "-" + day + }, // 缂栬緫 btnEdit(row) { this.editConfig.detailEnter = false @@ -291,9 +408,8 @@ setTimeout(() => { this.tableLoading = false }, 3000) - // this.editRow = row; - // this.$refs.add.islook = true; }, + // 纭鍙戣揣 btnConfirm(row) { let string = "鏄惁鎻愪氦锛�" @@ -412,6 +528,98 @@ setTimeout(() => { this.tableLoading = false }, 3000) + }, + // top 琛岀偣鍑� + tableRowClick(row) { + this.selectRow = row + if (row.status == 1 && this.TabsIndex == 0) { + getPurchaseInfo({ id: row.id }).then((res) => { + if (res.code == 200) { + this.productTableList.tableInfomation = res.data.productList + } else { + this.$message.error(res.msg ? res.msg + "," : "" + "鑾峰彇淇℃伅澶辫触锛�") + } + }) + } else if (this.TabsIndex == 1 && row.status == 1) { + this.productTableList.tableInfomation = [] + } else { + getOperationInfo({ id: row.id }).then((res) => { + if (res.code == 200) { + this.productTableList.tableInfomation = res.data + } else { + this.$message.error(res.msg ? res.msg + "," : "" + "鑾峰彇淇℃伅澶辫触锛�") + } + }) + } + }, + // bom 鍒楄〃 + setBottomList() { + this.productTableList = { + selectIndex: true, + tableInfomation: [], + allcol: [], + showcol: this.showBottomCol, + tableColumn: this.setColumnVisible(this.showBottomCol, this.tableBottomColumn) + } + this.setTableList(this.productTableList) + }, + setTableList(tableList) { + tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label) + this.searchOptions = [] + for (let i = 0; i < tableList.tableColumn.length; i++) { + const label = tableList.tableColumn[i].label + const value = tableList.tableColumn[i].prop + this.searchOptions.push({ value: value, label: label }) + } + }, + // bottom 浜у搧淇℃伅 + selBottomTableCol(val) { + this.showcol = val + this.productTableList.tableColumn = this.setColumnVisible(val, this.tableBottomColumn) + }, + //鑾峰彇褰撳墠閫変腑璧勬簮鐨刬d + getTab(tab) { + this.TabsIndex = tab + if (this.TabsIndex == 0) { + // 浜у搧淇℃伅鍒楄〃 + this.tableBottomColumn = this.productColumn + this.showBottomCol = this.showProductCol + this.setBottomList() + this.getProductInventoryInfo(this.selectRow) + } else if (this.TabsIndex == 1) { + // 鏀惰揣淇℃伅鍒楄〃 + this.tableBottomColumn = this.recriveColumn + this.showBottomCol = this.showReceiveCol + this.setBottomList() + this.getProductInventoryInfo(this.selectRow) + } + }, + // 鐘舵�� + getStatus(val) { + return val === 1 ? "寰呯‘璁�" : val === 2 ? "寰呭嚭搴�" : val === 3 ? "鍑哄簱瀹屾垚" : val === 4 ? "宸插叧闂�" : "--" + }, + // 鑾峰彇浜у搧/鏀惰揣淇℃伅 + async getProductInventoryInfo(row) { + console.log(row) + if (this.TabsIndex == 0 && row.status == 1) { + getPurchaseInfo({ id: row.id }).then((res) => { + if (res.code == 200) { + this.productTableList.tableInfomation = res.data.productList + } else { + this.$message.error(res.msg ? res.msg + "," : "" + "鑾峰彇淇℃伅澶辫触锛�") + } + }) + } else if (this.TabsIndex == 1 && row.status == 1) { + this.productTableList.tableInfomation = [] + } else { + getOperationInfo({ id: row.id }).then((res) => { + if (res.code == 200) { + this.productTableList.tableInfomation = res.data + } else { + this.$message.error(res.msg ? res.msg + "," : "" + "鑾峰彇淇℃伅澶辫触锛�") + } + }) + } } } } @@ -444,15 +652,51 @@ padding: 10px 20px; border-radius: 12px; height: calc(100% - 92px); - &-card { + .content-top { background-color: #fff; border-radius: 12px; - height: 100%; - overflow: hidden; + min-height: 70px; + height: 48%; + position: relative; + .list-view { + height: calc(100% - 60px); + } } - .list-view { - height: calc(100% - 60px); - overflow: hidden; + .content-bottom { + .bottom-tabs { + height: 40px; + line-height: 40px; + background: #e6ecf2; + display: flex; + .tab-pane { + width: 100px; + margin-right: 20px; + font-size: 14px !important; + text-align: center; + cursor: pointer; + background: #2a78fb; + border-top-left-radius: 20px; + border-top-right-radius: 20px; + } + } + .lable-view { + background: #e6ecf2; + height: 40px; + line-height: 40px; + .name { + border-left: 4px solid #2a78fb; + padding-left: 10px; + } + } + background-color: #fff; + border-radius: 12px; + min-height: 70px; + height: calc(52% - 60px); + margin-top: 10px; + // padding: 10px 20px; + .list-view { + height: calc(100% - 10px); + } } .btn-pager { display: flex; diff --git a/src/views/supplierManage/supplier/AddNewProduct.vue b/src/views/supplierManage/supplier/AddNewProduct.vue index 3b493de..5c73f04 100644 --- a/src/views/supplierManage/supplier/AddNewProduct.vue +++ b/src/views/supplierManage/supplier/AddNewProduct.vue @@ -15,10 +15,13 @@ <div class="basic-info-view"> <CommonFormTableView ref="productTable" + :addTypeIdMultiple="true" :product-table-list="productTableList" :detail-enter="detailEnter" + :isOperate="isOperate" @inputContent="inputContent" @addProductClick="addProductClick" + @getSelectArray="getSelectArray" @emptyProductClick="emptyProductClick" @clearupProduct="clearupProduct" @selCommonName="selCommonName" @@ -63,6 +66,7 @@ isNoProduct: true, supplierId: this.addCommonConfig.infomation.supplierId, detailEnter: true, + isOperate: true, deliveryTime: this.addCommonConfig.infomation.deliveryTime, // 渚涜揣鏃堕暱 shippingDuration: this.addCommonConfig.infomation.shippingDuration, // 鐗╂祦鏃堕暱 purchasePrice: this.addCommonConfig.infomation.purchasePrice // 閲囪喘浠锋牸 @@ -144,8 +148,8 @@ } return params }, - handleProduct(item,row){ - this.editConfig.infomation.id=row.id + handleProduct(item, row) { + this.editConfig.infomation.id = row.id }, setTableForm() { if (this.editConfig.title === "娣诲姞") { @@ -160,15 +164,16 @@ number: "", price: 0, total: 0, - supplierId:this.supplierId + supplierId: this.supplierId } ] } else { - this.tableData = [{ ...this.editConfig.infomation}] + this.tableData = [{ ...this.editConfig.infomation }] this.detailEnter = true } this.productTableList = { tableData: this.tableData, + isReturn: true, tableColumn: [ { label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true, width: 250 }, { label: "浜у搧缂栫爜", prop: "number" }, @@ -182,36 +187,46 @@ }, // 浜у搧鍒楄〃杈撳叆 inputContent(val, prop, row) { - this.productId = row.productId - this.deliveryTime = row.deliveryTime - this.shippingDuration = row.shippingDuration - this.purchasePrice = row.purchasePrice this.tableData.map((item) => { - if (item.productId === row.productId) { + if (item.number === row.number) { item[prop] = val - item.supplierId =Number(this.supplierId) - item.deliveryTime = this.deliveryTime - item.shippingDuration = this.shippingDuration - item.purchasePrice = this.purchasePrice + item.supplierId = Number(this.supplierId) } }) }, // 浜у搧鏂板 addProductClick() { - this.productId++ - this.tableData.push({ - productId: this.productId, - id: 0, - amount: 0, - desc: "", - name: "", - number: "", - purchasePrice: 0, - total: 0, - deliveryTime: 0, - shippingDuration: 0, - supplierId: this.supplierId - }) + // this.productId++ + // this.tableData.push({ + // productId: this.productId, + // id: 0, + // amount: 0, + // desc: "", + // name: "", + // number: "", + // purchasePrice: 0, + // total: 0, + // deliveryTime: 0, + // shippingDuration: 0, + // supplierId: this.supplierId + // }) + }, + // 鏂板鏂瑰紡淇敼 + getSelectArray(val, index) { + console.log(val, "ddd99999") + if (this.tableData.length == 1 && this.tableData[0].number.length == 0) { + this.tableData = [] + } + if (index < this.tableData.length) { + this.tableData.splice(index, 1) + val.map((item, ind) => { + this.tableData.splice(index + ind, 0, item) + }) + } else { + this.tableData = this.tableData.concat(val) + } + this.productTableList.tableData = this.tableData + // this.showSummary.show = true }, // 浜у搧娓呯┖ emptyProductClick() { -- Gitblit v1.8.0