1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[22],{c919:function(t,e,a){"use strict";a("ccd9")},ccd9:function(t,e,a){},e6ff:function(t,e,a){"use strict";a.r(e);var l=function(){var t=this,e=t._self._c;return e("q-card",{staticClass:"q-pa-md shadow-5"},[e("div",{staticClass:"q-mb-md"},[e("div",{staticClass:"row"},[e("q-btn",{attrs:{label:"添加条件",icon:"add",color:"primary"},on:{click:t.addCondition}}),e("q-select",{staticClass:"q-ml-md",staticStyle:{width:"100px"},attrs:{options:["AND","OR"],dense:""},model:{value:t.logicOperator,callback:function(e){t.logicOperator=e},expression:"logicOperator"}})],1)]),e("draggable",{attrs:{list:t.conditions,handle:".handle"}},t._l(t.conditions,(function(a,l){return e("div",{key:a.id,staticClass:"row q-gutter-sm q-mb-md"},[e("q-icon",{staticClass:"handle text-grey-6",attrs:{name:"drag_indicator",size:"24px"}}),e("q-select",{staticStyle:{"min-width":"160px"},attrs:{options:t.fieldOptions,label:"字段",dense:"","emit-value":"","map-options":""},model:{value:a.field,callback:function(e){t.$set(a,"field",e)},expression:"condition.field"}}),e("q-select",{staticStyle:{"min-width":"130px"},attrs:{options:t.operatorOptions(a.field),label:"条件",dense:"","emit-value":"","map-options":""},model:{value:a.operator,callback:function(e){t.$set(a,"operator",e)},expression:"condition.operator"}}),"date"!==a.field?e(t.inputComponent(a.field),{tag:"component",staticClass:"col"}):[e("div",{staticClass:"row q-gutter-xs"},[e("q-select",{attrs:{options:t.yearOptions,label:"年",dense:"","emit-value":""},on:{"update:model-value":t.handleChange},model:{value:t.year,callback:function(e){t.year=e},expression:"year"}}),e("q-select",{attrs:{options:t.monthOptions,label:"月",dense:"","emit-value":"",disable:!t.year},on:{"update:model-value":t.handleChange},model:{value:t.month,callback:function(e){t.month=e},expression:"month"}}),e("q-select",{attrs:{options:t.dayOptions,label:"日",dense:"","emit-value":"",disable:!t.month},on:{"update:model-value":t.handleChange},model:{value:t.day,callback:function(e){t.day=e},expression:"day"}})],1)],e("q-btn",{attrs:{flat:"",round:"",icon:"delete",color:"negative"},on:{click:function(e){return t.removeCondition(l)}}})],2)})),0),e("div",{staticClass:"q-mt-md",attrs:{align:"right"}},[e("q-btn",{attrs:{label:"重置"},on:{click:t.resetConditions}}),e("q-btn",{attrs:{label:"执行查询",color:"primary"},on:{click:t.executeQuery}})],1),e("div",{staticClass:"q-mt-lg"},[e("q-card",{attrs:{flat:"",bordered:""}},[e("q-card-section",[e("div",{staticClass:"text-caption"},[t._v("生成查询条件:")]),e("pre",[t._v(t._s(t.generatedQuery))])]),e("q-card-actions",{attrs:{align:"right"}})],1)],1)],1)},n=[],o=a("b76a"),i=a.n(o),s=function(){var t=this,e=t._self._c;return e("div",{staticClass:"row q-gutter-xs"},[e("q-select",{attrs:{options:t.yearOptions,label:"年",dense:"","emit-value":""},on:{"update:model-value":t.handleChange},model:{value:t.year,callback:function(e){t.year=e},expression:"year"}}),e("q-select",{attrs:{options:t.monthOptions,label:"月",dense:"","emit-value":"",disable:!t.year},on:{"update:model-value":t.handleChange},model:{value:t.month,callback:function(e){t.month=e},expression:"month"}}),e("q-select",{attrs:{options:t.dayOptions,label:"日",dense:"","emit-value":"",disable:!t.month},on:{"update:model-value":t.handleChange},model:{value:t.day,callback:function(e){t.day=e},expression:"day"}})],1)},r=[],d=(a("ddb0"),{props:["modelValue"],emits:["update:modelValue"],data(){return{year:null,month:null,day:null}},computed:{yearOptions(){const t=(new Date).getFullYear();return Array.from({length:5},((e,a)=>t-a))},monthOptions(){return Array.from({length:12},((t,e)=>({label:`${e+1}月`,value:e+1})))},dayOptions(){if(!this.year||!this.month)return[];const t=new Date(this.year,this.month,0).getDate();return Array.from({length:t},((t,e)=>e+1))}},watch:{modelValue:{immediate:!0,handler(t){if(t){const[e,a,l]=t.split("-").map(Number);this.year=e||null,this.month=a||null,this.day=l||null}else this.clear()}}},methods:{handleChange(){let t=null;this.year&&(t=`${this.year}`,this.month&&(t+=`-${this.pad(this.month)}`,this.day&&(t+=`-${this.pad(this.day)}`))),this.$emit("update:modelValue",t)},pad(t){return t.toString().padStart(2,"0")},clear(){this.year=null,this.month=null,this.day=null}}}),c=d,u=a("42e1"),p=a("ddd8"),m=a("eebe"),h=a.n(m),b=Object(u["a"])(c,s,r,!1,null,null,null),v=b.exports;h()(b,"components",{QSelect:p["a"]});var y={components:{draggable:i.a,CustomDateInput:v},data(){return{conditions:[],logicOperator:"AND",fieldOptions:[{label:"物料编码",value:"material_code"},{label:"物料名称",value:"material_name"},{label:"批次号",value:"batch"},{label:"库存数量",value:"quantity"},{label:"入库日期",value:"date"}],operatorMap:{default:[{label:"等于",value:"eq"},{label:"包含",value:"contains"},{label:"开头为",value:"startswith"}],quantity:[{label:"大于",value:"gt"},{label:"等于",value:"eq"},{label:"小于",value:"lt"}],date:[{label:"之前",value:"lte"},{label:"之后",value:"gte"}]}}},computed:{generatedQuery(){return this.conditions.map((t=>{const e={eq:"",contains:"__icontains",startswith:"__istartswith",gt:"__gt",lt:"__lt",gte:"__gte",lte:"__lte"}[t.operator];return`${t.field}${e}=${t.value}`})).join(` ${this.logicOperator} `)},inputComponent(){return function(t){const e={material_code:"q-input",material_name:"q-input",batch:"q-input",quantity:"q-input",date:"CustomDateInput"};return e[t]||"q-input"}}},methods:{operatorOptions(t){return this.operatorMap[t]||this.operatorMap.default},addCondition(){this.conditions.push({id:Date.now(),field:"material_code",operator:"eq",value:"",..."date"===this.field&&{value:"2025-01-01"}})},getDefaultDate(){const t=new Date;return`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-01`},removeCondition(t){this.conditions.splice(t,1)},resetConditions(){this.conditions=[]},executeQuery(){console.log("执行查询:",this.generatedQuery)}}},g=y,f=(a("c919"),a("f09f")),q=a("9c40"),C=a("0016"),_=a("a370"),w=a("4b7e"),x=a("27f9"),O=Object(u["a"])(g,l,n,!1,null,"248852c7",null);e["default"]=O.exports;h()(O,"components",{QCard:f["a"],QBtn:q["a"],QSelect:p["a"],QIcon:C["a"],QCardSection:_["a"],QCardActions:w["a"],QInput:x["a"]})}}]);
|