| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- <template>
- <div>
- <div class="borderless">
- <div class="customer-head">
- <div class="customer-back">
- <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
- @click="backToList">返回列表
- </el-button>
- </div>
- <div class="add-customer-btn">
- <el-button type="primary" size="small" @click="editCustomer">
- 保存数据
- </el-button>
- </div>
- </div>
- <!-- <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle> -->
- <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
- <avue-form ref="form" class="trading-form" v-model="form" :option="option">
- <template slot="corpId">
- <ypj-corp v-model="form.corpId" :disabled="detailData.status == 1" @getCorpData="getCorpData"
- :dataInfo="true"></ypj-corp>
- </template>
- </avue-form>
- </trade-card>
- <trade-card title="商品信息" v-loading="loadingBtn">
- <avue-form ref="form" class="trading-form" v-model="form" :option="option2">
- <template slot="thisUsedProfit">
- <el-input-number v-model="form.thisUsedProfit" @change="amountChange" placeholder="请输入" size="small"
- :controls="false" style="width:100%;"></el-input-number>
- </template>
- </avue-form>
- <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
- @resetColumn="resetColumn" :cell-style="cellStyle" @row-save="rowSave" @row-update="addUpdate">
- <template slot="headerSerial">
- <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
- :disabled="detailData.status == 1" circle></el-button>
- </template>
- <template slot="cname" slot-scope="{ row, index }">
- <span style="display:flex">
- <el-select v-model="row.cname" placeholder="请选择" size="small" filterable
- @change="cnameChange(row, index)">
- <el-option v-for="item in goodsoptions" :key="item.itemId" :label="item.cname" :value="item.cname">
- </el-option>
- </el-select>
- </span>
- </template>
- <template slot="storageInQuantity" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.storageInQuantity" @change="countChange(row)" placeholder="请输入"
- size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.storageInQuantity }}</span>
- </template>
- <template slot="price" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.price" @change="countChange(row)" placeholder="请输入"
- size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.price }}</span>
- </template>
- <template slot="purchaseAmount" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.purchaseAmount" @change="countChange(row)" placeholder="请输入"
- size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.purchaseAmount }}</span>
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button size="small" type="text" @click="rowCell(row, index)">{{
- row.$cellEdit ? "保存" : "修改"
- }}</el-button>
- <el-button size="small" type="text" @click="rowDel(row, index)">删除
- </el-button>
- </template>
- </avue-crud>
- </trade-card>
- <fee-info :data="settlementList" :form="form" :detailData="detailData" v-loading="loadingBtn"></fee-info>
- <containerTitle title="上传附件"></containerTitle>
- <c-upload v-loading="loadingBtn" typeUpload="CD"
- deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="orderFilesList" display
- :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>
- <el-dialog :title="addressTitle" v-dialogDrag :visible.sync="addressVisible" class="avue-dialog avue-dialog--top"
- width="50%" append-to-body>
- <span>
- <el-tabs v-model="activeName">
- <el-tab-pane label="客户地址" name="first">
- <avue-form class="trading-form" v-model="form2" :option="optiontabs1"></avue-form>
- </el-tab-pane>
- <el-tab-pane label="物流地址" name="second">
- <avue-form class="trading-form" v-model="form3" :option="optiontabs2"></avue-form>
- </el-tab-pane>
- </el-tabs>
- </span>
- <div class="avue-dialog__footer">
- <el-button @click="addressVisible = false">取 消</el-button>
- <el-button @click="addressVisible = false" type="primary">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { optionList } from "./js/optionList";
- import { getDetails, submit, getCorpDetails, remove, getGoodsList } from "@/api/basicData/salesOrder";
- import feeInfo from "./components/feeInfo.vue";
- import { multiply, sum, subtract } from "@/util/calculate";
- export default {
- name: "index",
- data() {
- return {
- activeName: 'first',
- loadingBtn: false,
- addressTitle: null,
- addressVisible: false,
- form: {},
- form2: {
- },
- form3: {
- },
- data: [],
- option: {
- menuBtn: false,
- labelWidth: 90,
- column: [
- {
- label: "客户名称",
- prop: "corpId",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ],
- span: 8,
- },
- {
- label: "送货地址",
- prop: "arrivalAddress",
- type: 'select',
- dicData: [],
- props: {
- label: 'detailedAddress',
- value: 'detailedAddress'
- },
- allowCreate: true,
- filterable: true,
- span: 16,
- },
- {
- label: "销售日期",
- prop: "businesDate",
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd 00:00:00",
- span: 8,
- },
- {
- label: "计划收款日期",
- prop: "advanceCollectionDate",
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd 00:00:00",
- span: 8,
- },
- {
- label: "送货日期",
- prop: "requiredDeliveryDate",
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd 00:00:00",
- span: 8,
- },
- {
- label: "备注",
- prop: "orderRemark",
- placeholder: "打印时显示",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- option2: {
- menuBtn: false,
- labelWidth: 70,
- column: [
- {
- label: "税率",
- prop: "exchangeRate",
- type: "select",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
- dicUrl: "/api/blade-system/dict-biz/dictionary?code=tax_rate",
- span: 4,
- },
- {
- label: "订单金额",
- prop: "purchaseAmount",
- disabled: true,
- span: 4,
- },
- {
- label: "优惠金额",
- prop: "thisUsedProfit",
- span: 4,
- },
- {
- label: "合同金额",
- prop: "orderAmount",
- disabled: true,
- offset: 8,
- span: 4,
- }
- ]
- },
- optiontabs1: {
- menuBtn: false,
- labelWidth: 90,
- column: [
- {
- label: "简称",
- prop: "a",
- type: "select",
- span: 24,
- },
- {
- label: "地址",
- prop: "b",
- type: "select",
- span: 24,
- },
- {
- label: "详细地址",
- prop: "c",
- span: 24,
- },
- {
- label: "邮编",
- prop: "d",
- span: 24,
- },
- {
- label: "备注",
- prop: "e",
- type: 'textarea',
- minRows: 3,
- span: 24,
- },
- {
- label: "地址智能识别",
- prop: "ad",
- placeholder: "例:上海市徐汇区枫林街道斜土路100号",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- optiontabs2: {
- menuBtn: false,
- labelWidth: 80,
- column: [
- {
- label: "目的地",
- prop: "a",
- type: "select",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ],
- span: 24,
- },
- {
- label: "物流公司",
- prop: "b",
- span: 24,
- },
- {
- label: "电话",
- prop: "c",
- span: 24,
- },
- {
- label: "地址",
- prop: "d",
- span: 24,
- },
- {
- label: "详细地址",
- prop: "e",
- span: 24,
- },
- {
- label: "邮编",
- prop: "f",
- span: 24,
- },
- {
- label: "备注",
- prop: "remarks",
- type: "textarea",
- minRows: 3,
- span: 24,
- },
- {
- label: "地址智能识别",
- prop: "g",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- optionList: {},
- goodsoptions: [],
- settlementList: [],
- };
- },
- props: {
- detailData: {
- type: Object
- }
- },
- components: {
- feeInfo,
- },
- async created() {
- this.optionList = await this.getColumnData(
- this.getColumnName(212),
- optionList
- );
- if (this.detailData.id) {
- this.getDetail(this.detailData.id);
- }
- if (this.detailData.status == 1) {
- this.option.disabled = true;
- }
- this.getAllWorkDicts()
- getGoodsList(1, 10).then(res => {
- if (res.data.data.total > 0) {
- this.goodsoptions = res.data.data.records;
- if (Math.ceil(res.data.data.total / 10) > 1) {
- for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
- getGoodsList(i, 10).then(e => {
- this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
- });
- }
- }
- }
- });
- },
- methods: {
- getAllWorkDicts() {
- this.getWorkDicts("unit").then(res => {
- this.findObject(this.optionList.column, "unit").dicData = res.data.data;
- });
- this.$refs.crud.init();
- },
- cellStyle() {
- return "padding:0;height:40px;";
- },
- cnameChange(row) {
- console.log(row)
- if (row.cname) {
- this.goodsoptions.forEach(e => {
- if (e.cname == row.cname) {
- row.unit = e.unit
- row.price = e.standardPrice
- row.storageInQuantity = 1
- row.amount = e.standardPrice
- row.purchaseAmount = e.purchasePrice
- row.storageAmount = e.purchasePrice
- }
- })
- } else {
- row.unit = null
- row.price = null
- row.purchaseAmount = null
- }
- },
- amountChange() {
- let val = 0
- this.data.forEach(e => {
- val = sum(val, e.amount)
- this.form.purchaseAmount = val
- this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
- })
- },
- countChange(row) {
- row.amount = multiply(row.price, row.storageInQuantity)
- row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
- },
- getDetail(id) {
- this.loadingBtn = true
- getDetails({ id: id })
- .then(res => {
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList
- this.getAddress(res.data.data)
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- },
- getCorpData(row) {
- console.log(row)
- this.findObject(this.option.column, "arrivalAddress").dicData = row.corpsAddrList;
- // this.form.corpName = row.cname
- },
- getAddress(row) {
- getCorpDetails({ id: row.corpId }).then(res => {
- this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
- })
- },
- addRow() {
- this.data.push({ $cellEdit: true })
- },
- rowCell(row, index) {
- this.$refs.crud.rowCell(row, index)
- },
- rowSave(form, done) {
- done()
- },
- addUpdate(form, index, done, loading) {
- done()
- },
- rowDel(row, index) {
- this.$confirm("确定删除数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- if (row.id) {
- remove(row.id).then(res => {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.data.splice(index, 1);
- });
- } else {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.data.splice(index, 1);
- }
- });
- },
- //修改提交触发
- editCustomer() {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- this.loadingBtn = true;
- submit({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList })
- .then(res => {
- this.$message.success("保存成功");
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- } else {
- return false;
- }
- });
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(212),
- this.optionList
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout();
- });
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- async resetColumn() {
- this.optionList = optionList;
- const inSave = await this.delColumnData(
- this.getColumnName(212),
- optionList
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout();
- });
- this.getAllWorkDicts()
- this.$message.success("重置成功");
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- //返回列表
- backToList() {
- this.$emit("goBack");
- }
- },
- watch: {
- data: function (rows) {
- let val = 0
- rows.forEach(e => {
- val = sum(val, e.amount)
- this.form.purchaseAmount = val
- this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .trading-form ::v-deep .el-form-item {
- margin-bottom: 8px !important;
- }
- ::v-deep .el-dialog__body {
- padding: 0px 20px 15px 20px;
- }
- ::v-deep .el-form-item__error {
- display: none !important;
- }
- .img-form ::v-deep .el-form-item {
- height: 150px;
- line-height: 150px;
- margin-bottom: 8px !important;
- }
- .img-form ::v-deep .avue-upload__icon {
- font-size: 20px;
- width: 150px;
- height: 150px;
- line-height: 150px;
- }
- ::v-deep .el-table .cell {
- padding: 0 2px !important;
- }
- ::v-deep .avue-crud .el-table .el-form-item__label {
- left: -1px;
- }
- .addressTabs {
- display: flex;
- justify-content: center;
- span {
- width: 100px;
- font-size: 18px;
- font-weight: 600;
- text-align: center;
- }
- }
- </style>
|