123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <template>
- <div>
- <basic-container v-if="show" class="page-crad">
- <avue-crud
- ref="crud"
- :option="option"
- :data="dataList"
- v-model="form"
- :page.sync="page"
- :search.sync="search"
- @search-change="searchChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- :table-loading="loading"
- @saveColumn="saveColumn"
- :summary-method="summaryMethod"
- :cell-style="cellStyle"
- >
- <template slot-scope="{ row }" slot="salesCompany">
- <span>{{ row.salesCompanyName }}</span>
- </template>
- <template slot-scope="{ row }" slot="storageId">
- <span>{{ row.storageName }}</span>
- </template>
- <template slot-scope="{ row }" slot="createUser">
- <span>{{ row.createUserName }}</span>
- </template>
- <template slot-scope="scope" slot="corpId">
- {{ scope.row.corpsName }}
- </template>
- <template slot="storageIdSearch">
- <warehouse-select
- v-model="search.storageId"
- :configuration="configuration2"
- ></warehouse-select>
- </template>
- <template slot="businessDateSearch">
- <el-date-picker
- v-model="search.businessDate"
- type="daterange"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd HH:mm:ss"
- :default-time="['00:00:00', '23:59:59']"
- >
- </el-date-picker>
- </template>
- <template slot="createTimeSearch">
- <el-date-picker
- v-model="search.createTime"
- type="daterange"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd HH:mm:ss"
- :default-time="['00:00:00', '23:59:59']"
- >
- </el-date-picker>
- </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" disabled>复制新单</el-button>
- <el-button type="info" size="small">报表</el-button>
- </template>
- <template slot="corpIdSearch">
- <select-component
- v-model="search.corpId"
- :configuration="configuration"
- ></select-component>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button
- type="text"
- icon="el-icon-edit"
- size="small"
- @click.stop="editOpen(scope.row, 2)"
- >编辑
- </el-button>
- <el-button
- type="text"
- icon="el-icon-delete"
- size="small"
- @click.stop="rowDel(scope.row, scope.index)"
- >删除
- </el-button>
- </template>
- </avue-crud>
- </basic-container>
- <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
- </div>
- </template>
- <script>
- import option from "./config/mainList.json";
- import { getList, remove, gainUser } from "@/api/basicData/invoice";
- import detailPage from "./detailsPage.vue";
- import { micrometerFormat } from "@/util/validate";
- import { defaultDate } from "@/util/date";
- import _ from "lodash";
- export default {
- name: "customerInformation",
- data() {
- return {
- configuration: {
- multipleChoices: false,
- multiple: false,
- collapseTags: false,
- placeholder: "请点击右边按钮选择",
- dicData: []
- },
- configuration2: {
- multipleChoices: false,
- multiple: false,
- collapseTags: false,
- placeholder: "请点击右边按钮选择",
- dicData: []
- },
- search: {
- businessDate: defaultDate()
- },
- form: {},
- option: {},
- parentId: 0,
- dataList: [],
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0,
- pageSizes:[10,50,100,200,300,400,500]
- },
- show: true,
- detailData: {},
- loading: false
- };
- },
- components: { detailPage },
- async created() {
- this.option = await this.getColumnData(this.getColumnName(8), option);
- if (this.$route.query.pageType == "Generate") {
- this.newAdd();
- }
- let _this = this;
- this.option.column.forEach(e => {
- if (e.prop == "exchangeRate") {
- e.formatter = function(row) {
- return _this.textFormat(
- Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
- "0.00%"
- );
- };
- }
- if (e.prop == "creditAmount") {
- e.formatter = function(row) {
- return _this.textFormat(
- Number(row.creditAmount ? row.creditAmount : 0),
- "#,##0.00"
- );
- };
- }
- });
- gainUser().then(res => {
- this.findObject(this.option.column, "createUser").dicData = res.data.data;
- });
- },
- activated() {
- //当页面已打开并无法重新渲染时,用activated重新激活keepalive组件
- setTimeout(() => {
- if (this.$route.query.pageType == "Generate" && this.show) {
- this.newAdd();
- }
- }, 100);
- },
- methods: {
- cellStyle() {
- return "padding:0;height:40px;";
- },
- //删除列表后面的删除按钮触发触发(row, index, done)
- rowDel(row, index, done) {
- this.$confirm("确定删除数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- remove(row.id).then(res => {
- if (res.data.code == 200) {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.onLoad(this.page, this.search);
- }
- });
- });
- },
- //查看跳转页面
- beforeOpenPage(row, status) {
- this.detailData = {
- id: row.id,
- status: status
- };
- this.show = false;
- this.$store.commit("OUT_IN__DETAIL");
- },
- editOpen(row, status) {
- this.detailData = {
- id: row.id,
- status: status
- };
- this.show = false;
- this.$store.commit("OUT_IN__DETAIL");
- },
- //点击搜索按钮触发
- searchChange(params, done) {
- if (params.businessDate) {
- params.businessStartDate = params.businessDate[0];
- params.businessEndDate = params.businessDate[1];
- }
- if (params.createTime) {
- params.createStartTime = params.createTime[0];
- params.createEndTime = params.createTime[1];
- }
- delete params.businessDate;
- delete params.createTime;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- currentChange(val) {
- this.page.currentPage = val;
- },
- sizeChange(val) {
- this.page.currentPage = 1;
- this.page.pageSize = val;
- },
- onLoad(page, params) {
- if (this.search.businessDate && this.search.businessDate.length > 0) {
- params = {
- ...params,
- orderStartDate: this.search.businessDate[0],
- orderEndDate: this.search.businessDate[1]
- };
- delete params.businessDate;
- }
- this.loading = true;
- getList(page.currentPage, page.pageSize, params)
- .then(res => {
- this.dataList = res.data.data.records ? res.data.data.records : [];
- this.page.total = res.data.data.total;
- if (this.page.total) {
- this.option.height = window.innerHeight - 400;
- }
- })
- .finally(() => {
- this.loading = false;
- });
- },
- refreshChange() {
- this.onLoad(this.page, this.search);
- },
- newAdd() {
- this.show = false;
- this.$store.commit("OUT_IN__DETAIL");
- },
- goBack() {
- this.detailData = this.$options.data().detailData;
- if (this.$route.query.pageType == "Generate") {
- this.$router.$avueRouter.closeTag();
- this.$router.push({
- path: "/exportTrade/invoice/index"
- });
- }
- this.show = true;
- this.$store.commit("OUT_OUT_DETAIL");
- },
- summaryMethod({ columns, data }) {
- const sums = [];
- if (columns.length > 0) {
- columns.forEach((item, index) => {
- sums[0] = "合计";
- if (
- item.property == "totalQuantity" ||
- item.property == "deliveryAmount" ||
- item.property == "totalCost"
- ) {
- let qtySum = 0;
- let instoreSum = 0;
- let totalSum = 0;
- data.forEach(e => {
- qtySum = _.add(qtySum, Number(e.totalQuantity));
- instoreSum = _.add(instoreSum, Number(e.deliveryAmount));
- totalSum = _.add(totalSum, Number(e.totalCost));
- });
- //数量总计
- if (item.property == "totalQuantity") {
- sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
- }
- //入库金额总计
- if (item.property == "deliveryAmount") {
- sums[index] = micrometerFormat(instoreSum);
- }
- //金额总计
- if (item.property == "totalCost") {
- sums[index] = micrometerFormat(totalSum);
- }
- }
- });
- }
- return sums;
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(8),
- this.option
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- }
- },
- watch: {
- option: function() {
- this.search.businessDate = defaultDate();
- }
- }
- };
- </script>
- <style scoped>
- ::v-deep .select-component {
- display: flex;
- }
- .page-crad ::v-deep .basic-container__card {
- height: 94.2vh;
- }
- </style>
|