123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <template>
- <div>
- <basic-container v-show="show" class="page-crad">
- <avue-crud
- ref="crud"
- :option="option"
- :data="dataList"
- v-model="form"
- :page.sync="page"
- :search.sync="search"
- :table-loading="loading"
- :cell-style="cellStyle"
- @selection-change="selectionChange"
- @search-change="searchChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @search-reset="searchReset"
- @on-load="onLoad"
- @search-criteria-switch="searchCriteriaSwitch"
- @saveColumn="saveColumn"
- @resetColumn="resetColumn"
- @expand-change="expandChange"
- >
- <template slot="orderNo" slot-scope="scope">
- <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.orderNo }}</span>
- </template>
- <template slot="strCorpName" slot-scope="scope">
- <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.strCorpName }}</span>
- </template>
- <template slot="createUser" slot-scope="scope">
- <span>{{ scope.row.createUserName }}</span>
- </template>
- <template slot="amount" slot-scope="scope">
- <span>{{ scope.row.amount | decimalFormat }}</span>
- </template>
- <template slot="strCorpNameSearch">
- <crop-select
- v-model="search.corpId"
- corpType="GYS"
- ></crop-select>
- </template>
- <template slot="storageNameSearch">
- <warehouse-select
- v-model="search.storageId"
- :configuration="configurationWarehouse"/>
- </template>
- <template slot-scope="{ row }" slot="expand">
- <avue-crud
- :data="row.itemData"
- :option="itemOption"
- :table-loading="row.itemLoading"
- :cell-style="cellStyle"
- class="itemTable"
- ></avue-crud>
- </template>
- <template slot="menuLeft">
- <el-button
- type="primary"
- icon="el-icon-plus"
- size="small"
- @click.stop="newAdd()"
- >创建单据</el-button>
- <el-button
- type="success"
- size="small"
- icon="el-icon-plus"
- @click.stop="copyDoc()"
- :disabled="selection.length != 1"
- >复制单据</el-button>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button
- type="text"
- icon="el-icon-delete"
- size="small"
- @click.stop="rowDel(scope.row, scope.index)"
- :disabled="scope.row.status == 3"
- >删除
- </el-button>
- </template>
- </avue-crud>
- </basic-container>
- <detail-page
- @goBack="goBack"
- @copyOrder="copyOrder"
- :detailData="detailData"
- v-if="!show"
- />
- </div>
- </template>
- <script>
- import option from './config/mainList.json';
- import detailPage from "./detail";
- import { gainUser } from "@/api/basicData/customerInquiry";
- import {getPurchaseList, deleteDetails, dataDetail} from "@/api/dealer/purchase";
- export default {
- name: "index",
- components: { detailPage },
- data() {
- return {
- option: {},
- dataList: [],
- form: {},
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0,
- pageSizes: [10, 50, 100, 200, 300, 400, 500]
- },
- search: {},
- show: true,
- loading: false,
- selection: [],
- detailData: {},
- itemOption: {
- align: "center",
- header: false,
- menu: false,
- column: [
- {
- label: "产品编码",
- prop: "code",
- width: 138,
- overHidden: true
- },
- {
- label: "商品名称",
- prop: "cname",
- width: 138,
- overHidden: true
- },
- {
- label: "花纹",
- prop: "brandItem",
- width: 138,
- overHidden: true
- },
- {
- label: "负荷指数",
- prop: "specsOne",
- width: 138,
- overHidden: true
- },
- {
- label: "速度级别",
- prop: "specsTwo",
- width: 138,
- overHidden: true
- },
- {
- label: "单位",
- prop: "unit",
- width: 138,
- overHidden: true
- },
- {
- label: "数量",
- prop: "orderQuantity",
- width: 138,
- overHidden: true
- },
- {
- label: "尺寸",
- prop: "size",
- width: 138,
- overHidden: true
- },
- {
- label: "价格",
- prop: "price",
- width: 138,
- overHidden: true
- },
- {
- label: "小计",
- prop: "amount",
- width: 138,
- overHidden: true
- },
- ]
- },
- // 仓库配置
- configurationWarehouse: {
- multipleChoices: false,
- multiple: false,
- collapseTags: false,
- clearable: true,
- placeholder: "请点击右边按钮选择",
- dicData: [],
- },
- }
- },
- async created() {
- this.option = await this.getColumnData(this.getColumnName(81), option);
- gainUser().then(res => {
- this.findObject(this.option.column, "createUser").dicData = res.data.data;
- })
- let i = 0;
- this.option.column.forEach(item => {
- if (item.search) i++
- })
- if (i % 3 !== 0){
- const num = 3 - Number(i % 3)
- this.option.searchMenuSpan = num * 8;
- this.option.searchMenuPosition = "right";
- }
- },
- filters: {
- decimalFormat(num) {
- return num ? Number(num).toFixed(2) : "0.00";
- }
- },
- methods: {
- searchCriteriaSwitch(type) {
- if (type) {
- this.option.height = this.option.height - 70
- } else {
- this.option.height = this.option.height + 70
- }
- this.$refs.crud.getTableHeight();
- },
- newAdd() {
- this.show = false;
- },
- copyDoc() {},
- selectionChange(list) {
- this.selection = list;
- },
- //删除列表后面的删除按钮触发触发(row, index, done)
- rowDel(row, index, done) {
- this.$confirm("确定删除数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(res => {
- return deleteDetails(row.id)
- }).then(() => {
- this.dataList.splice(row.$index, 1)
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.page.currentPage = 1;
- this.onLoad(this.page)
- })
- },
- //点击搜索按钮触发
- searchChange(params, done) {
- this.onLoad(this.page, params);
- done();
- },
- currentChange(val) {
- this.page.currentPage = val;
- },
- sizeChange(val) {
- this.page.currentPage = 1;
- this.page.pageSize = val;
- },
- refreshChange() {
- this.onLoad(this.page, this.search);
- },
- searchReset() {
- this.onLoad(this.page, this.search);
- },
- cellStyle() {
- return "padding:0;height:40px;";
- },
- onLoad(page, params) {
- // 重置掉展开
- this.dataList.forEach(item => {
- this.$refs.crud.toggleRowExpansion(item, false)
- })
- let queryParams = Object.assign({}, params, {
- size: page.pageSize,
- current: page.currentPage,
- })
- if (queryParams.businesDate && queryParams.businesDate.length > 0) {
- queryParams = {
- ...queryParams,
- businesStartDate: queryParams.businesDate[0],
- businesEndDate: queryParams.businesDate[1],
- }
- }
- delete queryParams.businesDate;
- this.loading = true;
- getPurchaseList(queryParams).then(res => {
- res.data.data.records.forEach(e => {
- e.itemLoading = false;
- e.itemData = [];
- });
- this.dataList = res.data.data.records;
- this.page.total = res.data.data.total;
- this.option.height = window.innerHeight - 240;
- this.$nextTick(() => {
- this.$refs.crud.doLayout()
- })
- }).finally(() => {
- this.loading = false;
- })
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(81),
- this.option
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- this.$nextTick(() => {
- this.$refs.crud.doLayout()
- })
- }
- },
- async resetColumn() {
- this.option = option;
- const inSave = await this.delColumnData(this.getColumnName(81), option);
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout()
- })
- this.$message.success("重置成功");
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- goBack() {
- if (this.$route.query.id) {
- this.$router.$avueRouter.closeTag(this.$route.fullPath);
- this.$router.push({
- path: "/dealer/sales/index"
- });
- }
- this.detailData = this.$options.data().detailData;
- this.show = true;
- this.onLoad(this.page, this.search);
- },
- copyOrder(id) {
- this.show = true;
- this.detailData = {
- id: id,
- status: "copy"
- };
- this.$nextTick(() => {
- this.show = false;
- });
- },
- beforeOpenPage(row, index) {
- this.show = false;
- this.detailData = {
- id: row.id,
- query: true, // 表示只是查询
- };
- },
- expandChange(row) {
- if (this.dataList[row.$index].itemLoading == false) {
- this.dataList[row.$index].itemLoading = true;
- dataDetail(row.id)
- .then(res => {
- this.dataList[row.$index].itemData = res.data.data.orderItemsList? res.data.data.orderItemsList: [];
- })
- .finally(() => {
- this.dataList[row.$index].itemLoading = false;
- });
- }
- },
- },
- }
- </script>
- <style scoped>
- ::v-deep .select-component {
- display: flex;
- }
- .page-crad ::v-deep .basic-container__card {
- height: 94.2vh;
- }
- ::v-deep .el-table__expanded-cell[class*="cell"] {
- padding: 0px;
- }
- </style>
|