| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- <basic-container>
- <avue-crud
- ref="crud"
- :data="data"
- :option="optionTable"
- :page.sync="page"
- :search.sync="search"
- :table-loading="loading"
- :summary-method="summaryMethod"
- @row-del="rowDel"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @search-change="searchChange"
- @refresh-change="refreshChange"
- @on-load="getList"
- @saveColumn="saveColumn"
- >
- <template slot="corpIdSearch">
- <select-component
- v-model="search.corpId"
- :configuration="configuration"
- ></select-component>
- </template>
- <template slot="menuLeft">
- <el-button type="primary"
- size="small"
- icon="el-icon-plus"
- @click="addMainItems">新 单
- </el-button>
- <el-button size="small"
- type="info"
- @click.stop="openReport()"
- >导出报表
- </el-button>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button
- type="text"
- icon="el-icon-edit"
- size="small"
- @click.stop="editOpen(scope.row, scope.index)"
- >编辑
- </el-button>
- <el-button
- type="text"
- icon="el-icon-delete"
- size="small"
- :disabled="!scope.row.allowDelete"
- @click.stop="rowDel(scope.row, scope.index)"
- >删除
- </el-button>
- </template>
- <report-dialog
- :switchDialog="switchDialog"
- @onClose="onClose()"
- ></report-dialog>
- </avue-crud>
- </basic-container>
- </template>
- <script>
- import option from "./configuration/mainList.json";
- import { getList,deleteMain } from "@/api/workManagement/mainProject";
- import reportDialog from "@/components/report-dialog/main";
- import { micrometerFormat } from "@/util/validate";
- import _ from "lodash";
- export default {
- data() {
- return {
- switchDialog:false,
- loading: false,
- data: [],
- search:{},
- configuration:{
- multipleChoices:false,
- multiple:false,
- disabled:false,
- searchShow:true,
- collapseTags:false,
- clearable:true,
- placeholder:'请点击右边按钮选择',
- dicData:[]
- },
- optionTable: option,
- page: {
- currentPage: 1,
- total: 0,
- pageSize: 10
- }
- };
- },
- created() {
- // option.height = window.innerHeight - 380 ;
- },
- mounted() {
- },
- components: {
- reportDialog
- },
- methods: {
- //打印
- openReport() {
- this.switchDialog =! this.switchDialog;
- },
- //关闭打印
- onClose(val) {
- this.switchDialog = val;
- },
- //flag:0 判断是主营项目还是结算
- getList(page,params = {}) {
- params.flag = 0;
- this.loading = true;
- if(params){
- if (params.createTime != undefined) { //发货
- params.createStartDate = params.createTime[0]+ " " + "00:00:00";
- params.createEndDate = params.createTime[1] + " " + "23:59:59";
- this.$delete(params,'createTime')
- }
- }
- getList(page.currentPage, page.pageSize,params).then(res =>{
- this.data = res.data.data.records
- this.page.total = res.data.data.total
- this.loading = false
- })
- },
- //新单打开
- addMainItems(){
- this.$router.push({
- path: "/mainItems_detailsPage",
- query: {id: ''},
- });
- },
- //编辑打开
- editOpen(row, index){
- console.log(row)
- this.$router.push({
- path: "/mainItems_detailsPage",
- query: {id:row.id},
- });
- },
- searchChange(params, done) {
- this.getList(this.page, params);
- done();
- },
- refreshChange(params) {
- this.getList(this.page,params);
- },
- //删除列表后面的删除按钮触发触发(row, index, done)
- rowDel(row, index, done) {
- if(row.allowDelete){
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- deleteMain(row.id).then(res =>{
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- })
- // 数据回调进行刷新
- this.getList(this.page);
- });
- }else{
- this.$message({
- type: "warning",
- message: "当前项目存在已请核任务 不能删除!"
- });
- }
- },
- //修改时的修改按钮点击触发
- rowUpdate(row, index, done, loading) {
- setTimeout(() => {
- this.$message.success("修改成功");
- loading();
- done();
- }, 1000);
- },
- //新增修改时保存触发
- rowSave(row, done, loading) {
- setTimeout(() => {
- this.$message.success("保存成功");
- loading();
- done();
- }, 1000);
- },
- saveColumn(row, column) {
- console.log(row, column);
- },
- summaryMethod({ columns, data }) {
- const sums = [];
- if (columns.length > 0) {
- columns.forEach((item, index) => {
- sums[0] = "合计";
- if (
- item.property == "debitAmount" ||
- item.property == "settlmentAmount"
- ) {
- let qtySum = 0;
- let instoreSum = 0;
- data.forEach(e => {
- qtySum = _.add(qtySum, Number(e.debitAmount));
- instoreSum = _.add(instoreSum, Number(e.settlmentAmount));
- });
- if (item.property == "debitAmount") {
- sums[index] = micrometerFormat(qtySum);
- }
- if (item.property == "settlmentAmount") {
- sums[index] = micrometerFormat(instoreSum);
- }
- }
- });
- }
- return sums;
- },
- //打开详情页
- beforeOpenPage(row, index) {
- this.$router.push({
- path: "/mainItems_detailsPage",
- query: { id: JSON.stringify(row.prop1) }
- });
- }
- }
- };
- </script>
- <style></style>
|