zhangyanpeng
2024-08-27 a8961c1d00c17a5aa2658884df9479ed6fba94c3
module/fee/page/popup/popup_edit_fee_execute.html
@@ -15,19 +15,19 @@
            new FormVue({
               el: "#vbody",
               data: {
                  dataname: "fee_guide_settle_execute",
                  table_dataname: "fee_working_out_base_execute",
                  dataname: "fee_task_execute",
                  table_dataname: "v_fee_working_grant_detail",
                  title: "执行单信息",
                  dataRequest: [
                     {
                        name: "fee_working_out_base_execute", // 业务负责人字段
                        dataname: "fee_working_out_base_execute",
                        name: "v_fee_working_grant_detail", // 业务负责人字段
                        dataname: "v_fee_working_grant_detail",
                        url: "root/data/getEntitySet",
                        paramsobj: {dataname: "fee_working_out_base_execute", attachMeta: true, filter: "1<>1"},
                        paramsobj: {dataname: "v_fee_working_grant_detail", attachMeta: true, filter: "1<>1"},
                        isnotoption: true, //true:不是选项
                     }
                  ],
                  meta_fee_working_out_base_execute: [],
                  meta_v_fee_working_grant_detail: [],
                  
                  options_md_org_master: [],
                  md_bu_org_obj: {},
@@ -51,6 +51,7 @@
                  formFields: [],
                  
                  newformData: {
                     code: createBaseCode("ZX"),
                     state_code: "Input",
                     state_name: "录入",
                     is_active: true,
@@ -58,7 +59,9 @@
                     type_code: "Customer", // Standard标准价目表、Customer经销商价目表
                  },
                  formData: {},
                  formDataDefault: {
                     guide_id: "fee_guide_settle_execute"
                  },
                  isRefresh: true,
                  tableFields: [],
                  tableData: [],
@@ -92,13 +95,14 @@
                  approveremark: '',//填写理由
                  passOrRefuse:false,
                  loading_pass: false,
                  tablebuttonClick: []
               },
               created() {
                  this.popupParames = clone(Root.popupParames);
                  // this.title = this.popupParames.title || this.popupParames.text
                  if (this.popupParames.data) {
                     if (this.popupParames.data._datano) {
                        this.title = this.title + this.popupParames.data._datano;
                     if (this.popupParames.data.code) {
                        this.title = this.title + this.popupParames.data.code;
                     }
                     this.formData = clone(this.popupParames.data);
                  }
@@ -137,9 +141,9 @@
                        this.formAttr.disabled = true;
                        this.isapproval = true;
                        
                        if (this.formData.current_step_name && this.formData.current_step_name == "运营部门复核") {
                           this.isedit = true;
                        }
                        // if (this.formData.current_step_name && this.formData.current_step_name == "运营部门复核") {
                        //    this.isedit = true;
                        // }
                        
                     }
                     else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
@@ -176,15 +180,15 @@
                           }
                        }
                        // 获取变更的字段
                        if (me.dataRequestObj.fee_working_out_base_execute) {
                            let meta_ = me.dataRequestObj.fee_working_out_base_execute.meta.fee_working_out_base_execute.fields;
                        if (me.dataRequestObj.v_fee_working_grant_detail) {
                            let meta_ = me.dataRequestObj.v_fee_working_grant_detail.meta.v_fee_working_grant_detail.fields;
                           meta_.map(f=>{
                              f.isshow = "T";
                              if (f.field == "_qty_trans" || f.field == "_qty_cal" || f.field == "_qty_final" || f.field == "_amt_final") {
                              if (f.field == "grant_amt" || f.field == "grant_qty") {
                                 f.isfixed = "right";
                              }
                           })
                           me.meta_fee_working_out_base_execute = clone(meta_)
                           me.meta_v_fee_working_grant_detail = clone(meta_)
                        }
                        me.initData();
                     });
@@ -240,36 +244,14 @@
                           
                           metas.map(f=>{
                              f.isshow = "T";
                              if (f.field == "company_id") {
                                 // f.isshow = "F";
                                 f.options = me.options_md_org_master
                              if (f.field == "amt") {
                                 f.inputtype = "span"
                              }
                              if (f.field == "product_id") {
                                 f.props = {label: "value", value: "code", multiple: false};
                                 if (me.options_product.length) {
                                    f.options = clone(me.options_product);
                                 }
                                 else if (me.formData.bu_id && me.md_bu_product_obj[me.formData.bu_id]) {
                                    f.options = clone(me.md_bu_product_obj[me.formData.bu_id].children);
                                 }
                                 else {
                                    f.options = [];
                                 }
                              }
                              // if (f.field == "customer_name" && (me.popupParames.sceneCode == "addbyagreement" || me.popupParames.sceneCode == "editbyagreement")) {
                              //    f.disabled = true;
                              // }
                              // if ((f.field == "date_from" || f.field == "date_to") && (me.popupParames.sceneCode == "addbyagreement" || me.popupParames.sceneCode == "editbyagreement")) {
                              //    f.isshow = false;
                              // }
                              formFields_.push(clone(f));
                           })
                           if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
                              me.formFields = clone(formFields_);
                              me.tableFields = clone(me.meta_fee_working_out_base_execute);
                              me.tableFields = clone(me.meta_v_fee_working_grant_detail);
                              
                              //设置字段事件
                              me.tableFieldClick();
@@ -305,6 +287,11 @@
                              me.formFields = clone(formFields_);
                           }
                           me.onTableQuery();
                        }
                        // 是否需要弹出植入单选择窗
                        if(me.popupParames.sceneCode == "add") {
                           me.selectDetailPopup(true);
                        }
                     })
                  },
@@ -360,29 +347,124 @@
                     };
                     
                     this.tablefieldClick = {
                        _qty_trans: {
                        grant_qty: {
                            input: {
                              onchange: function(obj) {
                                 obj.row._qty_trans = obj.row._qty_trans * 1;
                                 if (obj.row._qty_cal) {
                                    obj.row._qty_final = (obj.row._qty_cal * 1) - (obj.row._qty_trans * 1)
                                    obj.row._amt_final = obj.row._qty_final  * obj.row._taxunitprice
                                 obj.row.grant_qty = obj.row.grant_qty * 1;
                                 var grant_price = 0;
                                 if (obj.row.grant_price) {
                                    grant_price = obj.row.grant_price
                                 }
                                 me.saveTableRow(obj.row);
                                 else if (table_row.grant_qty && table_row.grant_amt) {
                                    grant_price = table_row.grant_amt / table_row.grant_qty
                                 }
                                 obj.row.grant_amt = grant_price  * obj.row.grant_qty
                                 if (obj.row.id) {
                                    me.saveTableRow(obj.row);
                                 }
                              }
                            }
                        },
                     }
                     if (me.isedit) {
                        this.tablebuttonClick = [
                           {
                              // name: "新增", // type: "primary", // icon: "el-icon-edit",
                              isbuttonshow: me.isedit,
                              code: "add", isselected: false, classname: "",
                              onclick: function(obj) {
                                 me.selectDetailPopup(false)
                              }
                           },
                           // {
                           //    // name: "删除", // type: "primary", // icon: "el-icon-edit",
                           //    isbuttonshow: me.isedit,   type: "danger",
                           //    code: "delete", isselected: true, classname: "",
                           //    disabled: function(selectRowList) {
                           //       var bo_ = true;
                           //       if (selectRowList[0] && selectRowList[0].state_code == "Input") {
                           //          bo_ = false;
                           //       }
                           //       return bo_
                           //    },
                           //    onclick: function(obj) {
                           //       me.delData()
                           //    }
                           // },
                        ]
                     }
                  },
                  selectDetailPopup(isclose) {
                     var me = this;
                     //排除已选物料
                     var selectmap_ = {};
                     me.tableData.map(row=>{
                        if (row.sell_qty_id) {
                           var key_ = row.sell_qty_id
                           selectmap_[key_] = true
                        }
                     })
                     var filter_ = "";
                     var config = {
                        totab: false, //true: 以Tab导航的方式打开
                        width: "1000px",
                        height: "650px",
                        icon: "icon-product",
                        filter: filter_,
                        text: "选择执行流向",
                        id: "outBasePreGrantList" + "add",//totab: true时需设置,用于判断是否已打开此页面
                        url: "module/fee/page/popup/outBasePreGrantList.html",
                        delta: {selectmap: selectmap_},
                        sceneCode: "add", //"refuseedit",//"approval", //"add"//"browse",
                        closecallback: function() {
                           if (isclose) {
                              me.closeDialog();
                           }
                        },
                        callback: function(obj, callback) {
                           me.loadDetailData(obj);
                           if (callback) {
                              callback();
                           }
                        }
                     };
                     me.doPopupByPublic(config);
                  },
                  // 首次创建撤销单的植入单数据
                  loadDetailData(obj) {
                     var me = this;
                     me.formData.guide_id = me.formDataDefault.guide_id;
                     // 明细表格数据
                     var list_h = clone(obj.list); //购物车返回一个数组
                     var tableData_ = clone(me.tableData);
                     list_h.map(row=>{
                        console.log(row);
                        var table_row = clone(row);
                        table_row.id = null
                        table_row.task_id = null
                        table_row.data_no = row.datano
                        table_row.sell_qty_id = row.id
                        table_row.out_fee_id = row.out_fee_id
                        table_row.grant_qty = row.qty_check - (row.qty_grant ? row.qty_grant : 0)
                        table_row.grant_amt = row.amt_check ? row.amt_check/row.qty_check * (row.qty_check - (row.qty_grant ? row.qty_grant : 0)) : 0
                        table_row.grant_price = row.amt_check ? row.amt_check/row.qty_check : 0
                        tableData_.unshift(table_row)
                     })
                     me.tableData = clone(tableData_);
                  },
                  
                  saveTableRow(row) {
                     var me = this;
                     var entity_ = clone(row);
                     var entity = {
                        _qty_trans: entity_._qty_trans,
                        _qty_final: entity_._qty_final,
                        _amt_final: entity_._amt_final,
                        grant_qty: entity_.grant_qty,
                        grant_amt: entity_.grant_amt,
                        id: entity_.id
                     };
                     
@@ -567,11 +649,11 @@
                     let param_ = {
                        dataname: this.table_dataname,
                        filter: filter_,
                        orderby: "_dataNo",
                        page: {
                           pageno: this.pagenum,
                           pagesize: this.pagesize
                        },
                        orderby: "dataNo",
                        // page: {
                        //    pageno: this.pagenum,
                        //    pagesize: this.pagesize
                        // },
                        attachMeta: false
                     }
                     
@@ -582,7 +664,7 @@
                        if (result && result.data && result.data.entityset) {
                           var data_ = result.data.entityset;
                           me.tableData = data_;
                           me.total = result.data.page ? result.data.page.recordcount : 0;
                           // me.total = result.data.page ? result.data.page.recordcount : 0;
                        }
                        else {
                           me.total = 0;
@@ -613,26 +695,52 @@
                  saveRowTable(callback) {
                     var me = this;
                     var operator_ = "saveEntity";//保存
                     // if(me.iscommit) {
                     //    operator_ = "commit";//提交
                     // }
                     if(me.iscommit) {
                        operator_ = "commit";//提交
                     }
                     
                     var entity_ = clone(this.formData);
                     var entity = {
                        _qty_trans: entity_._qty_trans,
                        _qty_final: entity_._qty_final,
                        _amt_final: entity_._amt_final,
                        id: entity_.id
                     };
                     var tableData_v = clone(this.tableData);
                     // var entity = {
                     //    _qty_trans: entity_._qty_trans,
                     //    _qty_final: entity_._qty_final,
                     //    _amt_final: entity_._amt_final,
                     //    id: entity_.id
                     // };
                     var tableData_ = [];
                     var sum_grant_amt = 0;
                     tableData_v.map(r=>{
                        var r_ = {
                           data_no: r.data_no || r.datano,
                           sell_qty_id: r.sell_qty_id,
                           out_fee_id: r.out_fee_id,
                           grant_qty: r.grant_qty,
                           grant_amt: r.grant_amt,
                        }
                        if (r.id) {
                           r_.id = r.id
                        }
                        if (entity_.id) {
                           r_.task_id = entity_.id
                        }
                        if (r.grant_amt) {
                           sum_grant_amt += r.grant_amt;
                        }
                        tableData_.push(r_)
                     })
                     
                     entity_.amt = sum_grant_amt;
                     let param = {
                        dataname: me.dataname,
                        dataname: "fee_task_execute",
                        data: {},
                     }
                     if (me.formData.id) {
                        param.id = me.formData.id
                     }
                     param.data[me.dataname] = entity;
                     param.data["fee_task_execute"] = entity_;
                     param.data["fee_working_grant_detail"] = tableData_;
                     
                     Server.call("root/data/" + operator_, param, function(result) {
                        console.log(result);
@@ -895,11 +1003,17 @@
                           :pagesize="pagesize"
                           :pagenum="pagenum"
                           :total="total"
                           :table-height="dheight - 252 - 64"
                           :table-height="dheight - 147 - (isedit ? 28 : 0)"
                           :is-highlight-row="true"
                           :isdraggableorder="false"
                           :isshowtool="false"
                           :isbasicfilterfields="false"
                           :isshow-shoppingcart="false"
                           :isbasicfilterfields="false"
                           :isfilterfield="false"
                           :istablebuttons="false"
                           :is-pagination="false"
                           :table-buttons-click="tablebuttonClick"
                           
                           v-on:get-data="getData"
                        >
@@ -929,9 +1043,9 @@
                     <el-button  size="small" v-if="isapproval" type="danger" plain @click="onShowApproval('goback')">退回到上一步</el-button>
                  </el-button-group>
                  <el-button size="small" type="default" @click="closeDialog">取 消</el-button>
                  <!-- <el-button size="small" v-if="isedit || isrefuseedit" type="primary" :loading="loading_save" @click="saveRowTable()":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
                  <el-button size="small" v-if="isedit || isrefuseedit" type="primary" :loading="loading_save" @click="saveRowTable()":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
                  <el-button size="small" v-if="isedit && !formData.agreement_id" type="success" :loading="loading_submit" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
                   -->
                  <el-button size="small" v-if="isrefuseedit" type="success" @click="">再次提交</el-button>
                  
                  <el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('approve')">通 过</el-button>