| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164 |
- <template>
- <el-form :model="form" ref="form">
- <ele-pro-table
- ref="table"
- :needPage="false"
- :columns="columns"
- max-height="500px"
- :span-method="objectSpanMethod"
- :datasource="form.resultList"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- class="time-form"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <slot name="generateContracts"></slot>
- <el-row
- type="flex"
- justify="end"
- align="middle"
- style="margin-right: 15px"
- >
- <el-popconfirm
- class="ele-action"
- title="确定要删除吗?"
- @confirm="removeSupplier"
- v-if="status !== 'Detail'"
- >
- <template v-slot:reference>
- <el-link
- type="danger"
- title="删除供应商"
- :underline="false"
- icon="el-icon-delete"
- >
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </el-row>
- </template>
- <template v-slot:supplierName="{ row, $index }">
- {{ form.supplierName }}
- </template>
- <template v-slot:supplierTotalPrice="{ row, $index }">
- {{ form.totalPrice }}
- </template>
- <template v-slot:preferentialPrice="{ row, $index }">
- <el-form-item
- prop="preferentialPrice"
- v-if="status !== 'Detail'"
- :rules="{
- required: true,
- message: '请输入优惠后总价',
- trigger: 'blur'
- }"
- >
- <el-input v-model="form.preferentialPrice" type="number"></el-input>
- </el-form-item>
- <span v-else>
- {{ form.preferentialPrice }}
- </span>
- </template>
- <template v-slot:settlementMode="{ row, $index }">
- <el-form-item>
- <DictSelection
- dictName="结算方式"
- clearable
- v-model="form.settlementMode"
- @itemChange="chaengMode"
- :disabled="status == 'Detail'"
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:deliveryDate="{ row, $index }">
- <el-form-item
- prop="deliveryDate"
- v-if="status !== 'Detail'"
- :rules="{
- required: true,
- message: '请选择交货日期',
- trigger: 'change'
- }"
- >
- <el-date-picker
- style="width: 100%"
- clearable
- type="date"
- :disabled="status == 'Detail'"
- v-model="form.deliveryDate"
- value-format="yyyy-MM-dd"
- placeholder="请选择日期"
- @change="deliveryDateChange"
- >
- </el-date-picker>
- </el-form-item>
- <span v-else>
- {{ form.deliveryDate }}
- </span>
- </template>
- <template v-slot:taxRate="{ row, $index }">
- <el-form-item
- v-if="status !== 'Detail'"
- :rules="{
- required: isTaxRate == 1 ? true : '',
- message: '请输入税率',
- trigger: 'change'
- }"
- >
- <el-input
- v-model="row.taxRate"
- style="width: 100%"
- :disabled="status == 'Detail'"
- @input="getNotaxSinglePrice"
- >
- <template slot="suffix">%</template>
- </el-input>
- </el-form-item>
- <span v-else>
- {{ row.taxRate ? row.taxRate + '%' : '' }}
- </span>
- </template>
- <template v-slot:files="{ row, $index }">
- <el-form-item>
- <fileMain
- v-model="form.files"
- :type="status == 'Detail' ? 'view' : ''"
- ></fileMain>
- </el-form-item>
- </template>
- <template v-slot:isWinner="{ row, $index }">
- <el-form-item
- v-if="status !== 'Detail'"
- :prop="'resultList.' + $index + '.isWinner'"
- :rules="{
- required: true,
- message: '请选择是否中标',
- trigger: 'change'
- }"
- >
- <el-select v-model="row.isWinner" :disabled="status == 'Detail'">
- <el-option label="是" :value="1"></el-option>
- <el-option label="否" :value="0"></el-option>
- </el-select>
- </el-form-item>
- <span v-else>
- {{ row.isWinner == 1 ? '是' : '否' }}
- </span>
- </template>
- <template
- v-slot:supplierProductName="{ row, $index }"
- v-if="status !== 'Detail'"
- >
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'resultList.' + $index + '.supplierProductName'"
- :rules="{
- required: true,
- message: '请输入供应商产品名称',
- trigger: 'change'
- }"
- >
- <el-input
- v-model="row.supplierProductName"
- placeholder="请输入"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:supplierProductCode="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.supplierProductCode"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:deliveryDays="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input v-model="scope.row.deliveryDays"></el-input>
- </el-form-item>
- </template>
- <template v-slot:guaranteePeriod="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.guaranteePeriod"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:guaranteePeriodUnitCode="scope">
- <el-form-item style="margin-bottom: 20px">
- <DictSelection
- dictName="质保期单位"
- clearable
- v-model="scope.row.guaranteePeriodUnitCode"
- :disabled="status == 'Detail'"
- @itemChange="chaengUnitCode"
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:singlePrice="scope" v-if="status !== 'Detail'">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'resultList.' + scope.$index + '.singlePrice'"
- :rules="{
- required: true,
- message: '请输入采购单价',
- trigger: 'change'
- }"
- >
- <el-input
- @input="changeCount(scope.row, scope.$index)"
- v-model="scope.row.singlePrice"
- :disabled="status == 'Detail'"
- type="number"
- >
- <template slot="suffix">元</template>
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:notaxSinglePrice="scope">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.notaxSinglePrice"
- placeholder="请输入"
- type="number"
- readonly
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:totalCount="scope" v-if="status !== 'Detail'">
- <el-form-item
- :prop="'resultList.' + scope.$index + '.totalCount'"
- :rules="{
- required: true,
- message: '请输入数字',
- trigger: 'blur'
- }"
- >
- <el-input
- @input="changeCount(scope.row, scope.$index)"
- v-model="scope.row.totalCount"
- :disabled="status == 'Detail'"
- placeholder="请输入"
- type="number"
- ></el-input>
- </el-form-item>
- </template>
- <!-- <template v-slot:totalPrice="scope">
- <span>{{
- totalPrice(scope.row.totalCount, scope.row.singlePrice, scope.row)
- }}</span>
- </template> -->
- <template v-slot:provenance="scope">
- <el-form-item>
- <DictSelection
- dictName="产地"
- clearable
- :disabled="status == 'Detail'"
- v-model="scope.row.provenance"
- multiple
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:modelType="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.modelType"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:specification="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.specification"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:remark="scope" v-if="status !== 'Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-input
- v-model="scope.row.remark"
- type="textarea"
- placeholder="请输入"
- :disabled="status == 'Detail'"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:purchaseCount="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'resultList.' + scope.$index + '.purchaseCount'"
- :rules="{
- required: true,
- message: '请输入数量',
- trigger: 'change'
- }"
- >
- <el-input
- v-model="scope.row.purchaseCount"
- placeholder="请输入数量"
- type="number"
- :disabled="status == 'Detail'"
- :min="0"
- @input="changeCount(scope.row, scope.$index)"
- >
- <template slot="append">
- <el-select
- v-model="scope.row.purchaseUnitId"
- style="width: 80px"
- @change="changeCount(scope.row, scope.$index)"
- :disabled="status == 'Detail'"
- >
- <el-option
- :label="item.conversionUnit"
- :value="item.id"
- @click.native="packingChange(item, scope.$index)"
- v-for="(item, index) in scope.row.packageDispositionList"
- :key="index"
- ></el-option>
- </el-select>
- </template>
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:singleWeight="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :rules="{
- required: false,
- pattern: numberReg,
- trigger: 'change'
- }"
- :prop="'resultList.' + scope.$index + '.singleWeight'"
- >
- <el-input
- v-model="scope.row.singleWeight"
- @input="changeCount(scope.row, scope.$index)"
- placeholder="请输入"
- >
- <template slot="append">
- {{ scope.row.weightUnit }}
- </template>
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:purchaseUnit="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'resultList.' + scope.$index + '.purchaseUnitId'"
- >
- <el-select
- v-model="scope.row.purchaseUnitId"
- style="width: 100%"
- :disabled="status == 'Detail'"
- @change="changeCount(scope.row, scope.$index)"
- >
- <el-option
- :label="item.conversionUnit"
- :value="item.id"
- @click.native="packingChange(item, scope.$index)"
- v-for="(item, index) in scope.row.packageDispositionList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- </template>
- <template v-slot:isRequired="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- </ele-pro-table>
- </el-form>
- </template>
- <script>
- import { numberReg } from 'ele-admin';
- import dictMixins from '@/mixins/dictMixins';
- import fileUpload from '@/components/upload/fileUpload';
- import { copyObj } from '@/utils/util';
- import { getFile } from '@/api/system/file';
- // import fileMain from '@/components/addDoc/index.vue';
- import { getInventoryTotalAPI } from '@/api/wms';
- import { listByContactId } from '@/api/saleManage/contact';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import { parameterGetByCode } from '@/api/main/index.js';
- import { levelList } from '@/enum/dict.js';
- import { changeCount } from '@/BIZComponents/setProduct.js';
- export default {
- mixins: [dictMixins, tabMixins],
- components: {
- // fileMain,
- fileUpload
- // headList
- },
- props: {
- obj: {
- default: () => {
- return {};
- }
- },
- status: {
- default: 'edit'
- },
- radio: {
- default: ''
- },
- isUpdate: {
- default: false
- }
- },
- data() {
- const defaultForm = {
- key: null,
- endTime: '',
- isFirst: 0,
- name: ''
- };
- return {
- numberReg,
- defaultForm,
- radio1: '',
- cacheKeyUrl: 'eom-purchasingManage-inquiryTable',
- form: {
- resultList: [
- {
- supplierProductCode: '',
- deliveryDays: '',
- guaranteePeriod: '',
- guaranteePeriodUnitCode: '',
- guaranteePeriodUnitName: '',
- measuringUnit: '',
- modelType: '',
- productCode: '',
- isWinner: '',
- remark: '',
- singlePrice: '',
- specification: '',
- supplierProductName: '',
- technicalAnswerName: '',
- technicalParams: '',
- totalCount: '',
- totalPrice: ''
- }
- ]
- },
- dataList: [],
- spanArr: [],
- isTaxRate: 0
- };
- },
- computed: {
- columns() {
- return [
- {
- width: 50,
- label: '序号',
- type: 'index',
- columnKey: 'index',
- align: 'center',
- fixed: 'left'
- },
- {
- minWidth: 120,
- prop: 'supplierName',
- label: '供应商',
- slot: 'supplierName',
- align: 'center',
- showOverflowTooltip: true,
- isMerge: true,
- fixed: 'left'
- },
- {
- minWidth: 80,
- prop: 'supplierTotalPrice',
- label: '总价',
- slot: 'supplierTotalPrice',
- align: 'center',
- showOverflowTooltip: true,
- isMerge: true,
- fixed: 'left'
- },
- {
- minWidth: 140,
- prop: 'preferentialPrice',
- label: '优惠后总价',
- slot: 'preferentialPrice',
- headerSlot: 'isRequired',
- align: 'center',
- showOverflowTooltip: true,
- isMerge: true,
- fixed: 'left'
- },
- {
- minWidth: 120,
- prop: 'settlementMode',
- label: '结算方式',
- slot: 'settlementMode',
- headerSlot: 'isRequired',
- align: 'center',
- showOverflowTooltip: true,
- isMerge: true,
- fixed: 'left'
- },
- {
- minWidth: 160,
- prop: 'deliveryDate',
- label: '交货日期',
- slot: 'deliveryDate',
- headerSlot: 'isRequired',
- align: 'center',
- showOverflowTooltip: true,
- isMerge: true,
- fixed: 'left'
- },
- {
- minWidth: 100,
- prop: 'productCode',
- label: '编码',
- slot: 'productCode',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- minWidth: 100,
- prop: 'productName',
- label: '产品名称',
- slot: 'productName',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- minWidth: 100,
- prop: 'isWinner',
- label: '是否中标',
- slot: 'isWinner',
- align: 'center',
- headerSlot: 'isRequired',
- showOverflowTooltip: true
- },
- {
- minWidth: 140,
- prop: 'supplierProductCode',
- label: '供应商产品编码',
- slot: 'supplierProductCode',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- minWidth: 160,
- prop: 'supplierProductName',
- label: '供应商产品名称',
- slot: 'supplierProductName',
- headerSlot: 'isRequired',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- minWidth: 120,
- prop: 'goodsLevel',
- label: '物品级别',
- formatter: (_row, _column, cellValue) => {
- return levelList.find((item) => item.value == _row.goodsLevel)
- ?.label;
- },
- align: 'center'
- },
- {
- minWidth: 130,
- prop: 'reqTotalCount',
- label: '需求数量',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- if (row.reqTotalCount) {
- return row.reqTotalCount + ' ' + (row.measuringUnit || '');
- }
- },
- align: 'center'
- },
- {
- width: 250,
- prop: 'purchaseCount',
- label: '数量',
- slot: 'purchaseCount',
- headerSlot: 'isRequired',
- align: 'center'
- },
- {
- minWidth: 130,
- prop: 'totalCount',
- label: '购买数量',
- formatter: (row, column) => {
- if (row.totalCount) {
- return row.totalCount + ' ' + (row.measuringUnit || '');
- }
- },
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'availableCountBase',
- label: '库存数量',
- align: 'center'
- },
- {
- width: 180,
- prop: 'singleWeight',
- label: '单重',
- slot: 'singleWeight',
- align: 'center'
- },
- {
- width: 150,
- prop: 'totalWeight',
- label: '总重',
- slot: 'totalWeight',
- align: 'center',
- formatter: (row, column) => {
- if (row.totalWeight) {
- return row.totalWeight + ' ' + (row.weightUnit || '');
- }
- }
- },
- {
- minWidth: 120,
- prop: 'modelType',
- label: '型号',
- slot: 'modelType',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'specification',
- label: '规格',
- slot: 'specification',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'minimumOrderQuantity',
- label: '最低订购量',
- formatter: (row, column) => {
- if (row.minimumOrderQuantity) {
- return (
- row.minimumOrderQuantity + ' ' + (row.measuringUnit || '')
- );
- }
- },
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'doneTotalCount',
- label: '已采数量',
- formatter: (row, column) => {
- if (row.doneTotalCount) {
- return row.doneTotalCount + ' ' + (row.measuringUnit || '');
- }
- },
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'waitTotalCount',
- label: '待采数量',
- formatter: (row, column) => {
- if (row.waitTotalCount) {
- return row.waitTotalCount + ' ' + (row.measuringUnit || '');
- }
- },
- align: 'center'
- },
- {
- minWidth: 140,
- prop: 'singlePrice',
- label: '采购单价',
- slot: 'singlePrice',
- headerSlot: 'isRequired',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- width: 180,
- prop: 'notaxSinglePrice',
- label: '不含税单价',
- // slot: 'notaxSinglePrice',
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'totalPrice',
- label: '采购金额',
- slot: 'totalPrice',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 150,
- prop: 'taskName',
- label: '工序',
- slot: 'taskName',
- align: 'center'
- },
- {
- width: 110,
- prop: 'batchNo',
- label: '批次号',
- slot: 'batchNo',
- align: 'center'
- },
- {
- prop: 'provenance',
- label: '产地',
- slot: 'provenance',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 200
- },
- {
- minWidth: 120,
- prop: 'modelKey',
- label: '机型',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'colorKey',
- showOverflowTooltip: true,
- label: '颜色',
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'deliveryDays',
- label: '交期(天)',
- slot: 'deliveryDays',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 100,
- prop: 'guaranteePeriod',
- label: '有效期',
- slot: 'guaranteePeriod',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'guaranteePeriodUnitCode',
- label: '有效期单位',
- slot: 'guaranteePeriodUnitCode',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'packingSpecification',
- align: 'center',
- label: '包装规格',
- showOverflowTooltip: true
- },
- {
- minWidth: 220,
- prop: 'remark',
- label: '备注',
- slot: 'remark',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 90,
- prop: 'taxRate',
- label: '税率',
- slot: 'taxRate',
- align: 'center',
- headerSlot: this.isTaxRate == 1 ? 'isRequired' : '',
- // isMerge: true,
- showOverflowTooltip: true
- },
- {
- minWidth: 220,
- prop: 'files',
- label: '附件',
- slot: 'files',
- align: 'center',
- isMerge: true,
- showOverflowTooltip: true
- }
- ];
- }
- },
- watch: {
- radio(n, v) {
- this.radio1 = n;
- }
- },
- created() {
- parameterGetByCode({
- code: 'eom_purchasingManage_inquiryManage_taxRate'
- }).then((res) => {
- this.isTaxRate = res.value;
- console.log(this.isTaxRate, 'this.isTaxRate');
- });
- this.obj.resultList.forEach((item) => {
- this.obj['deliveryDate'] =
- this.obj.deliveryDate || item.expectReceiveDate;
- });
- this.form = copyObj(this.obj);
- console.log(this.form, '111');
- this.radio1 = this.radio;
- this.getSpanArr();
- this.setDeliveryDays();
- this.setIsInquiry();
- this.getInventoryTotalAPI();
- this.getListByContactId();
- // this.dataList=copyObj(this.list)
- },
- methods: {
- //计算交期
- setDeliveryDays() {
- console.log(this.form.resultList);
- this.form.resultList.forEach((item, index) => {
- let day =
- this.form.deliveryDate &&
- (new Date(this.form.deliveryDate).getTime() -
- new Date().getTime()) /
- 1000 /
- 60 /
- 60 /
- 24;
- this.$set(
- this.form.resultList[index],
- 'deliveryDays',
- Math.ceil(day) || 1
- );
- // item.deliveryDays =
- });
- this.$forceUpdate();
- },
- objectSpanMethod({ row, column, rowIndex, columnIndex }) {
- if (this.columns[columnIndex]?.isMerge) {
- const _row = this.spanArr[rowIndex]?.supplierName || 0;
- const _col = _row > 0 ? 1 : 0;
- return {
- rowspan: _row,
- colspan: _col
- };
- }
- return {
- rowspan: 1,
- colspan: 1
- };
- },
- async getInventoryTotalAPI() {
- let codeList = this.form.resultList
- .filter((item) => item.productCode)
- .map((item) => item.productCode);
- //获取仓库库存
- let inventoryTotalList = await getInventoryTotalAPI(codeList);
- this.form.resultList
- .filter((item) => item.productCode)
- .forEach((item, index) => {
- let find =
- inventoryTotalList.find((key) => key.code == item.productCode) ||
- {};
- // item.availableCountBase = find.availableCountBase;
- this.$set(
- this.form.resultList[index],
- 'availableCountBase',
- find.availableCountBase
- );
- });
- },
- //获取最新订购量
- async getListByContactId() {
- let productIds = this.form.resultList
- .filter((item) => item.productId)
- .map((item) => item.productId);
- if (productIds?.length > 0) {
- const data = await listByContactId({
- contactId: this.form.supplierId,
- productIds
- });
- this.form.resultList
- .filter((item) => item.productCode)
- .forEach((item, index) => {
- let pData = data.find((val) => val.productId == item.productId);
- if (pData) {
- this.$set(
- this.form.resultList[index],
- 'minimumOrderQuantity',
- pData.minimumOrderQuantity
- );
- }
- });
- }
- },
- setIsInquiry() {
- return;
- this.$emit('setIsInquiry');
- },
- packingChange(item, index) {
- this.$set(
- this.form.resultList[index],
- 'purchaseUnit',
- item.conversionUnit
- );
- },
- //改变数量
- changeCount(row, index) {
- this.$set(
- this.form.resultList,
- index,
- changeCount(row, {
- countKey: 'purchaseCount',
- unitKey: 'purchaseUnit',
- unitIdKey: 'purchaseUnitId'
- })
- );
- this.getNotaxSinglePrice();
- this.totalPriceAll();
- this.$forceUpdate();
- },
- //计算不含税单价
- getNotaxSinglePrice() {
- this.form.resultList.forEach((item, index) => {
- if (item.singlePrice && item.taxRate) {
- this.$set(
- this.form.resultList[index],
- 'notaxSinglePrice',
- parseFloat(
- (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
- )
- );
- } else {
- this.$set(this.form.resultList[index], 'notaxSinglePrice', '');
- }
- });
- },
- deliveryDateChange(row) {
- this.$emit('deliveryDateChange', (data) => {
- let is = false,
- iSexpectReceiveDate = false;
- if (data.length > 0) {
- data.forEach((item) => {
- if (
- new Date(this.form.deliveryDate).getTime() >
- new Date(item.expectReceiveDate).getTime()
- ) {
- is = true;
- }
- if (item.expectReceiveDate) {
- iSexpectReceiveDate = true;
- }
- });
- }
- if (is && iSexpectReceiveDate) {
- this.$message.warning('交货日期大于到货日期');
- }
- });
- this.setDeliveryDays();
- },
- getSpanArr() {
- let pos = 0;
- this.spanArr = [];
- this.form.resultList.forEach((item, index) => {
- if (index === 0) {
- let obj = {};
- this.columns.forEach((col) => {
- if (col.isMerge) {
- obj[col.prop] = 1;
- }
- });
- this.spanArr.push(obj);
- } else {
- let nameSame =
- item.supplierName ===
- this.form.resultList[index - 1].supplierName;
- if (nameSame) {
- this.spanArr[pos].supplierName += 1;
- this.spanArr.push({
- supplierName: 0,
- supplierTotalPrice: 0,
- preferentialPrice: 0,
- settlementMode: '4',
- taxRate: 0,
- files: 0,
- deliveryDate: 0
- });
- } else {
- pos = index;
- let obj = {};
- this.columns.forEach((col) => {
- if (col.isMerge) {
- obj[col.prop] = 1;
- }
- });
- this.spanArr.push(obj);
- }
- }
- });
- },
- downloadFile(file) {
- getFile({ objectName: file.storePath }, file.name);
- },
- //
- // changeGetPrice(row) {
- // if (row.singlePrice && row.totalCount) {
- // let num = 0;
- // this.form.resultList.forEach((item) => {
- // num += item.totalPrice || 0;
- // });
- // this.form.preferentialPrice = parseFloat(num.toFixed(2));
- // }
- // this.setIsInquiry();
- // this.getNotaxSinglePrice();
- // },
- //计算销售金额
- // totalPrice(a, b, row) {
- // if (!a || !b) {
- // return;
- // }
- // row.totalPrice = parseFloat((a * b).toFixed(2));
- // this.totalPriceAll();
- // return row.totalPrice;
- // },
- //计算销售总价
- totalPriceAll() {
- let num = 0;
- this.form.resultList.forEach((item) => {
- num += +item.totalPrice || 0;
- });
- this.form.totalPrice = parseFloat(num.toFixed(2));
- this.form.preferentialPrice = this.form.totalPrice;
- },
- // 返回列表数据
- getTableValue() {
- return this.form;
- },
- chaengMode(data) {
- this.form.settlementModeName = data.dictValue;
- },
- chaengUnitCode(data) {
- this.form.settlementModeName = data.dictValue;
- },
- //修改回显
- putTableValue(data) {
- this.form.resultList = copyObj(data);
- this.getListByContactId();
- this.setDeliveryDays();
- this.setIsInquiry();
- },
- remove(productCode) {
- let index = this.form.resultList.findIndex(
- (item) => item.productCode == productCode
- );
- this.form.resultList.splice(index, 1);
- this.setIsInquiry();
- this.setSort();
- },
- removeSupplier() {
- this.$emit('removeSupplier', this.form.supplierId);
- },
- // 清空表格
- restTable() {
- this.form.resultList = [];
- },
- // 重新排序
- setSort() {
- this.form.resultList.forEach((n, index) => {
- n.key = index + 1;
- });
- },
- validateForm(callback) {
- //开始表单校验
- this.$refs.form.validate((valid, errors) => {
- callback(valid, errors);
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .headbox {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .amount {
- font-size: 14px;
- font-weight: bold;
- }
- }
- .time-form .el-form-item {
- margin-bottom: 0 !important;
- }
- ::v-deep .period {
- display: flex;
- .borderleftnone {
- .el-input--medium .el-input__inner {
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
- }
- }
- .borderrightnone {
- .el-input--medium .el-input__inner {
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
- }
- }
- }
- ::v-deep .time-form tbody > tr:hover > td {
- background-color: transparent !important;
- }
- ::v-deep .time-form .el-table tr {
- background-color: #ffffff;
- }
- ::v-deep .el-upload-list--text {
- width: 75%;
- }
- </style>
|