| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <template>
- <el-form ref="form" :model="form" :rules="rules">
- <ele-pro-table
- ref="table"
- :needPage="false"
- :columns="columns"
- :toolkit="[]"
- max-height="500px"
- :datasource="form.datasource"
- cache-key="systemRoleTable17"
- class="time-form"
- :selection.sync="selection"
- >
-
- <template v-slot:files="scope">
- <el-form-item >
- <el-link
- v-for="link in scope.row.files"
- :key="link.id"
- type="primary"
- :underline="false"
- @click="downloadFile(link)"
- >
- {{ link.name }}
- </el-link>
- </el-form-item>
- </template>
-
- <template v-slot:supplierIds="scope">
- <el-form-item >
- <el-select
- v-model="scope.row['supplierIds']"
- clearable
- filterable
- multiple
- collapse-tags
- :disabled="status=='Detail'"
- >
- <el-option
- v-for="i in scope.row.supplierList"
- :key="i.id"
- :value="i.id"
- :label="i.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </template>
-
- <template v-slot:add="scope" v-if="status!='Detail'">
- <el-form-item style="margin-bottom: 20px">
- <el-button type="primary" @click="openSupplier(scope.row)"
- >新增报价单</el-button
- >
- </el-form-item>
- </template>
- <template v-slot:action="scope" v-if="status!='Detail'">
- <el-popconfirm
- class="ele-action"
- title="确定要删除吗?"
- @confirm="remove(scope.$index, scope.row.productCode)"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- <!-- <head-list ref="headRef" @changeParent="changeAnswer"></head-list> -->
- </el-form>
- </template>
- <script>
- import { numberReg } from 'ele-admin';
- import dictMixins from '@/mixins/dictMixins';
- import fileUpload from '@/components/upload/fileUpload';
- import { getFile } from '@/api/system/file';
- import { getByCode } from '@/api/system/dictionary-data';
- import { getInventoryTotalAPI } from '@/api/bpm/components/wms';
- import fileMain from '@/components/addDoc/index.vue';
- // import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
- import {lbjtList } from '@/enum/dict.js';
- export default {
- mixins: [dictMixins],
- components: {
- fileMain,
- fileUpload
- // headList
- },
- props: {
- acceptUnpack: {
- default: ''
- },
- status: {
- default: ''
- },
- },
- data() {
- const defaultForm = {
- key: null,
- endTime: '',
- isFirst: 0,
- name: ''
- };
- return {
- numberReg,
- defaultForm,
- supplierList: [],
- selection: [],
- // resultList:'',
- form: {
- datasource: []
- },
- dictList: {},
- files: [],
- rules: {}
- };
- },
- computed: {
- canHandl() {
- return this.form.datasource.length;
- },
- columns() {
- return [
- {
- width: 50,
- label: '序号',
- type: 'index',
- columnKey: 'index',
- align: 'center',
- fixed: 'left'
- },
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- fixed: 'left'
- },
- {
- minWidth: 180,
- slot: 'add',
- label: '新增报价',
- showOverflowTooltip: true,
- fixed: 'left',
- align: 'center',
- show:this.status!='Detail'
- },
- {
- minWidth: 100,
- label: '状态',
- fixed: 'left',
- filters: [
- { value: 0, text: '未核价' },
- { value: 1, text: '部分核价' },
- { value: 2, text: '全部核价完成' }
- ],
- filterMethod: this.isInquiryFn,
- formatter: (row, column) => {
- return row.isInquiry == 1
- ? '部分核价'
- : row.isInquiry == 2
- ? '全部核价完成'
- : '未核价';
- },
- align: 'center'
- },
- {
- minWidth: 100,
- prop: 'productCategoryName',
- label: '分类',
- slot: 'productCategoryName',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 100,
- prop: 'productCode',
- label: '编码',
- slot: 'productCode',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 140,
- prop: 'productName',
- label: '名称',
- slot: 'productName',
- headerSlot: 'productNameHeader',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 200,
- prop: 'supplierIds',
- label: '供应商选择',
- slot: 'supplierIds',
- align: 'center',
- filters: this.supplierList,
- filterMethod: this.filterMethod
- },
- {
- minWidth: 100,
- prop: 'productBrand',
- label: '牌号',
- slot: 'productBrand',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'totalCount',
- label: '数量',
- slot: 'totalCount',
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'availableCountBase',
- label: '库存数量',
- slot: 'availableCountBase',
- align: 'center'
- },
- {
- minWidth: 80,
- prop: 'measuringUnit',
- label: '单位',
- slot: 'measuringUnit',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 130,
- prop: 'modelType',
- label: '型号',
- slot: 'modelType',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- minWidth: 120,
- prop: 'specification',
- label: '规格',
- slot: 'specification',
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- width: 120,
- prop: 'totalWeight',
- label: '重量',
- slot: 'totalWeight',
- align: 'center'
- },
- {
- minWidth: 220,
- prop: 'taskName',
- label: '工序',
- slot: 'taskName',
- align: 'center'
- },
- {
- width: 110,
- prop: 'batchNo',
- label: '批次号',
- slot: 'batchNo',
- align: 'center'
- },
- {
- prop: 'provenance',
- label: '产地',
- slot: 'provenance',
- align: 'center',
- minWidth: 200,
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return row.provenance && row.provenance.length
- ? row.provenance
- .map((item) => this.getDictValue('产地', item ))
- .join(',')
- : '';
- }
- },
- {
- minWidth: 120,
- prop: 'imgCode',
- align: 'center',
- label: '图号/件号',
- showOverflowTooltip: true
- },
- {
- minWidth: 120,
- prop: 'produceType',
- align: 'center',
- label: '属性类型',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- if(row.produceType){
- return row.produceType.map(item=>{
- return lbjtList[item]
- }).toString()
- }
- }
- },
- // {
- // minWidth: 120,
- // prop: 'approvalNumber',
- // align: 'center',
- // label: '批准文号',
- // showOverflowTooltip: true
- // },
- {
- minWidth: 120,
- prop: 'packingSpecification',
- align: 'center',
- label: '包装规格',
- showOverflowTooltip: true
- },
- // {
- // width: 130,
- // prop: 'brand',
- // label: '品牌',
- // slot: 'brand'
- // },
- {
- minWidth: 170,
- prop: 'expectReceiveDate',
- label: '到货日期',
- slot: 'expectReceiveDate',
- align: 'center'
- },
- {
- minWidth: 140,
- prop: 'files',
- label: '附件',
- slot: 'files',
- align: 'center'
- },
- {
- minWidth: 220,
- prop: 'remark',
- label: '备注',
- slot: 'remark',
- align: 'center'
- }
- // {
- // columnKey: 'action',
- // label: '操作',
- // width: 120,
- // align: 'center',
- // resizable: false,
- // slot: 'action',
- // fixed: 'right',
- // showOverflowTooltip: true
- // }
- ];
- }
- },
- created() {
- this.requestDict('产地');
- this.getDictList('productionType');
- },
- methods: {
- getDictV(code, val) {
- if (!this.dictList[code]) return '';
- return this.dictList[code].find((item) => item.value == val)?.label;
- },
- async getDictList(code) {
- let { data: res } = await getByCode(code);
- this.dictList[code] = res.map((item) => {
- let values = Object.keys(item);
- return {
- value: values[0],
- label: item[values[0]]
- };
- });
- },
- downloadFile(file) {
- getFile({ objectName: file.storePath }, file.name);
- },
- // 返回列表数据
- getTableValue() {
- let comitDatasource = this.form.datasource;
- if (comitDatasource.length === 0) return [];
- comitDatasource.forEach((v) => {
- v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
- v.files = v.files || null;
- });
- return comitDatasource;
- },
- setIsInquiry(list) {
- // return;
- this.form.datasource.forEach((productItem, index) => {
- //产品清单
- let isInquiry = 0,
- totalCountS = [];
- list.forEach((item) => {
- //供应商列表
- item.resultList.forEach((val) => {
- //供应商产品
- if (val.productCode == productItem.productCode&&val.batchNo == productItem.batchNo&&val.taskId == productItem.taskId) {
- totalCountS.push(
- Number(val.totalCount || 0) +
- Number(productItem.doneTotalCount || 0)
- );
- }
- });
- });
- if (totalCountS.length > 0) {
- this.$set(
- this.form.datasource[index],
- 'isInquiry',
- Math.max(...totalCountS) >= productItem.totalCount ? 2 : 1
- );
- } else {
- // this.$set(this.form.datasource[index], 'isInquiry', 0);
- }
- console.log(totalCountS, 'codeS');
- });
- },
- filterMethod(value, row, column) {
- let ids = row.supplierIds
- if (ids.length > 0 && ids.includes(value)) {
- return row;
- }
- },
- isInquiryFn(value, row, column) {
- if (value == row.isInquiry) {
- return row;
- }
- },
- //修改回显
- async putTableValue(data) {
- if (data && data?.length) {
- let supplierList = [],
- supplierIds = [];
- this.form.datasource = data;
- let codeList = this.form.datasource.map((item) => item.productCode);
- //获取仓库库存
- let inventoryTotalList = await getInventoryTotalAPI(codeList);
- this.form.datasource.forEach((item, index) => {
- let find =
- inventoryTotalList.find((key) => key.code == item.productCode) ||
- {};
- // item.availableCountBase = find.availableCountBase;
- this.$set(
- this.form.datasource[index],
- 'availableCountBase',
- find.availableCountBase
- );
- supplierList.push(...item.supplierList);
- });
- supplierIds = Array.from(
- new Set(supplierList.map((item) => item.id))
- );
- this.supplierList = supplierIds.map((id) => {
- let data = supplierList.find((item) => item.id == id);
- return {
- text: data.name,
- value: data.id
- };
- });
- this.$refs.table.reload();
- }
- },
- handleSupplierSelect(row) {
- this.$emit('supplierSelect', row);
- },
- //选择产品
- handParent() {
- this.$refs.productListRef.open();
- },
- //选择产品回调
- changeParent(obj, idx) {
- obj['productBrand'] = obj.brandNum;
- obj['productCode'] = obj.code;
- obj['productName'] = obj.name;
- obj['productCategoryName'] = obj.categoryLevelPath;
- obj['productCategoryId'] = obj.categoryLevelId;
- this.form.datasource.push(obj);
- },
- remove(i, productCode) {
- if (!this.acceptUnpack) {
- this.$message.warning('本采购计划不能拆单');
- return;
- }
- this.form.datasource.splice(i, 1);
- this.$emit('delList', productCode);
- },
- // 清空表格
- restTable() {
- this.form.datasource = [];
- },
- openSupplier(row) {
- this.$emit('supplierSelect', row);
- },
- // 添加
- handlAdd() {
- let item = JSON.parse(JSON.stringify(this.defaultForm));
- item.key = this.form.datasource.length + 1;
- this.form.datasource.push(item);
- },
- validateForm(callback) {
- //开始表单校验
- this.$refs.form.validate((valid) => {
- callback(valid);
- });
- }
- }
- };
- </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;
- }
- </style>
|