"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[5280],{6913:function(t,e,n){n.r(e),n.d(e,{default:function(){return u}});var a=function(){var t=this,e=t._self._c;return t.docKinds?e("select-docs",{ref:"selectDocs",attrs:{docKinds:t.docKinds,title:t.docProp.DOCPROP_NAME,values:t.values,canCreate:t.canCreate,multiple:t.multiple,getStructure:t.getStructure,getData:t.getData,fetchData:t.fetchData,columnChange:t.columnChange,columnOrder:t.columnOrder,sortChange:t.sortChange},on:{close:function(e){return t.$emit("close")},change:function(e){return t.$emit("change",e)},"document-create":function(e){return t.$emit("document-create")},"document-open":function(e){return t.$emit("document-open",e)},changeDocKindId:function(e){t.curDocKindId=e}}}):t._e()},r=[],o=n(3216),i=n(8559),c={name:"ModalSelectPropDocs",components:{SelectDocs:()=>Promise.all([n.e(7661),n.e(8169),n.e(6062)]).then(n.bind(n,8940))},props:{values:{type:Array,default(){return[]}},canCreate:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},parentDocId:{type:Number,default:null},availableKindIds:{type:Array,default:null}},data(){return{optionsInterface:null,docKinds:null,docProp:null,dataParams:null,curDocKindId:null,curRow:0}},mounted(){this.$emit("init")},methods:{async open(t){if(this.docKinds=null,await this.$nextTick(),this.docProp=t,this.docKinds=await o.vd.select("CARD_GET_REF_LINKS_CS",{DOCPROP_ID:this.docProp.DOCPROP_ID},100),null!==this.availableKindIds&&(this.docKinds=this.docKinds.filter((t=>this.availableKindIds.includes(t.DOCKIND_ID)))),0===this.docKinds.length)throw"CARD_GET_REF_LINKS ("+this.docProp.DOCPROP_ID+") is empty"},close(){this.$refs.selectDocs&&this.$refs.selectDocs.close()},async getStructure(){return console.log("getStructure this.docProp",this,this.docProp),await o.vd.select("BR_CARABI_REFLIST_STRUC4_CS",{dockind_id_prop:this.curDocKindId,docprop_id:this.docProp.DOCPROP_ID},1e3)},async getData(t){return this.curRow=0,this.dataParams=t,await this.loadData(t.count)},async fetchData(t){let e=await this.loadData(t);return e.data},async loadData(t){let e=this.dataParams,n=i.A.convert_sort(e.pq_sort),a=i.A.convert_filter(e.pq_filter),r={DOCUMENT_ID:this.parentDocId,DOCPROP_ID:this.docProp.DOCPROP_ID,DOCKIND_ID_PROP:this.curDocKindId,STATUS_LIST:null,FILTER:e.context,FILTER_COLS:a,FILTER_PRESET:null,XML_FILTER:e.xmlFilter,ORDER_BY:n,RES_TREE_VALUE:e.curClassifId},c=await o.vd.query("CRM_GET_DOCLIST_REF_DATA_SEARCH9_CS",r,t,this.curRow);return this.curRow+=c.RESULT.length,{data:c.RESULT,count:c.CNT?parseInt(c.CNT):0}},async columnChange(t){await o.vd.query("SET_USER_COLUMN_PROP",{carabi_doclist_id:this.docProp.DOCPROP_ID,width:t.WIDTH?t.WIDTH:0,visible:t.VISIBLE?1:0,column_name:t.PROP_SYS_NAME})},async columnOrder(t){await o.vd.query("CRM_SET_USER_COLUMN_SHOW_ORDER",{COLUMN_NAME:t.column,BEFORE_COLUMN_NAME:t.nextColumn,CARABI_DOCLIST_ID:this.docProp.DOCPROP_ID})},async sortChange(t){await o.vd.query("SET_USER_COLUMN_ORDERBY",{column_name:t.fieldName,orderby:t.direction,carabi_doclist_id:this.docProp.DOCPROP_ID})}}},l=c,d=n(1656),s=(0,d.A)(l,a,r,!1,null,null,null),u=s.exports},8559:function(t,e){class n{convert_params(t,e){let n={};for(let a in e)n[a]="",void 0!==t[e[a]]&&(n[a]=t[e[a]]);return n}convert_sort(t){if(!t)return"";t=JSON.parse(t);let e="";for(let n in t){let a=t[n];""!=e&&(e+=","),e+=a.dataIndx+" "+("up"==a.dir?"ASC":"DESC")}return e}convert_filter(t){return JSON.stringify({filter:this.convert_filter_obj(t)})}convert_filter_obj(t){if(!t)return[];t=JSON.parse(t);let e=[],n={begin:"=",gte:">=",lte:"<=",between:">="};if(t&&t.data)for(let a in t.data){let r=t.data[a];void 0!==n[r.condition]&&e.push({field_name:r.dataIndx,value:r.value,operator:n[r.condition]}),"between"==r.condition&&e.push({field_name:r.dataIndx,value:r.value2,operator:"<="})}return e}calc_full_count(t,e,n,a){let r=(e-1)*n+a;return t<r&&(t=a==n?(e+1)*n:r),t}fix_row_count(t,e,n,a){let r=e+a;return t<r&&(t=a===n?e+2*n:r),t}}e.A=new n}}]);
//# sourceMappingURL=ModalSelectPropDocs.e938fa94.js.map