From 550634ebb41ca4e82c5e5b64417534065d68e150 Mon Sep 17 00:00:00 2001 From: cuiqian2004 <cuiqian2004@163.com> Date: 星期四, 27 二月 2025 16:27:08 +0800 Subject: [PATCH] test --- pages/modal/5601.vue | 685 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 560 insertions(+), 125 deletions(-) diff --git a/pages/modal/5601.vue b/pages/modal/5601.vue index 52a5dd6..e16e920 100644 --- a/pages/modal/5601.vue +++ b/pages/modal/5601.vue @@ -4,7 +4,7 @@ <uni-forms ref="baseForm" label-align="right"> <view v-for="(item,index) in head_styledef.form.items" :key="index" class="v-head-style"> <!-- 鏅�甯冨眬 --> - <uni-forms-item v-if="item.name != 'Layout'" :label="item.label +'锛� " + <uni-forms-item v-if="item.name != 'Layout'" :label="item.label ?item.label +'锛�:'' " :label-width="item.labelWidth+'px'"> <uni-data-picker v-if="item.name=='Select'" :class="item.disabled?'input-disabled':''" v-model="item.value" :localdata="item.dict" @change="onEnterChange(item)" @@ -21,15 +21,36 @@ <text v-if="item.setting.suffix" class="uni-icon" :class="[item.setting.suffix]" @click="classAttr_extButton(item)"></text> </view> + <!-- 澶嶉�妗�--> + <checkbox-group v-if="item.name=='Checkbox'" :class="item.disabled?'input-disabled':''" + :disabled="item.disabled" @change="onCheckBoxValue" :data-attr="item.fieldId" + :data-index="index"> + <label v-for="(item2) in item.selections" :key="item2.value"> + <checkbox :value="item2.value" :checked="item.value.includes(item2.value)" /> + <text>{{item2.label}}</text> + </label> + </checkbox-group> + <!-- 鍗曢�妗�--> + <radio-group v-if="item.name=='Radio'" :class="item.disabled?'input-disabled':''" + :disabled="item.disabled" @change="onRadioBoxValue" :data-attr="item.fieldId" + :data-index="index"> + <label v-for="(item2) in item.selections" :key="item2.value"> + <radio :value="item2.value" :checked="item2.value === item.value" /> + <text>{{item2.label}}</text> + </label> + </radio-group> + <!-- Switch寮�叧 --> + <switch class="input-switch" v-if="item.name=='Switch'" :class="item.disabled?'input-disabled':''" + :disabled="item.disabled" v-model="item.value" @change="onEnterChange(item)" /> </uni-forms-item> <!-- 鏍呮牸甯冨眬 --> <uni-row v-else :gutter="item.setting.gutter"> <uni-col :span=" item.setting.spanList && item.setting.spanList[key]? item.setting.spanList[key] : 24 / item.setting.col" v-for="(col,key) in item.setting.colList"> - <uni-forms-item :label="col.label +'锛�" :label-width="col.labelWidth+'px'"> + <uni-forms-item :label="col.label ? col.label +'锛�:''" :label-width="col.labelWidth+'px'"> <uni-data-picker v-if="col.name=='Select'" :class="col.disabled?'input-disabled':''" - v-model="col.value" :localdata="col.dict" @change="onEnterChange(item)" + v-model="col.value" :localdata="col.dict" @change="onEnterChange(col)" :readonly="col.disabled" :clear-icon="false" :popup-title="col.label"></uni-data-picker> <view class="input-wrapper" v-if="col.name=='Input' || col.name=='InputNumber'"> <text v-if="col.setting.prefix" class="uni-icon" :class="[col.setting.prefix]" @@ -43,6 +64,27 @@ <text v-if="col.setting.suffix" class="uni-icon" :class="[col.setting.suffix]" @click="classAttr_extButton(col)"></text> </view> + <!-- 澶嶉�妗�--> + <checkbox-group v-if="col.name=='Checkbox'" :class="col.disabled?'input-disabled':''" + :disabled="col.disabled" @change="onCheckBoxValue" :data-attr="col.fieldId" + :data-index="index" :data-iindex="key"> + <label v-for="(col2) in col.selections" :key="col2.value"> + <checkbox :value="col2.value" :checked="col.value.includes(col2.value)" /> + <text>{{col2.label}}</text> + </label> + </checkbox-group> + <!-- 鍗曢�妗�--> + <radio-group v-if="col.name=='Radio'" :class="col.disabled?'input-disabled':''" + :disabled="col.disabled" @change="onRadioBoxValue" :data-attr="col.fieldId" + :data-index="index" :data-iindex="key"> + <label v-for="(col2) in col.selections" :key="col2.value"> + <radio :value="col2.value" :checked="col2.value === col.value" /> + <text>{{col2.label}}</text> + </label> + </radio-group> + <!-- Switch寮�叧 --> + <switch v-if="col.name=='Switch'" :class="col.disabled?'input-disabled':''" + :disabled="col.disabled" v-model="col.value" @change="onEnterChange(col)" /> </uni-forms-item> </uni-col> </uni-row> @@ -102,25 +144,42 @@ </uni-row> </div> </div> - <div class="dv-panel-button"> + <div class="dv-panel-button" + v-if="pageData.Select_Button==true || pageData.Row_Button.length > 0"> <checkbox v-if="pageData.Select_Button==true" :model="ii" :checked="style.SelBut_Checked" /> <!-- <text></text> --> - <!-- <button type="primary" @click="savaItem(ii)" v-if="param.Sub_Page[0].OK_Button==true">淇濆瓨</Button> --> - <button type="warn" @tap="delItem(pageData,ii)" - v-if="pageData.Del_Button==true">{{translateSys('delete')}}</button> + <button size="mini" v-for="(btn,btnIndex) in pageData.Row_Button" + :key="btnIndex" :type="btn.FunCode == 'Delete' ? 'warn' : 'primary'" + @click="onRowBtnClick(btn, pageData,ii)"> + <Icon v-if="btn.Style == 'img' || btn.Style == 'img_text'" + class="Img" /> + {{(btn.Style == 'text'|| btn.Style == 'img_text') ? btn.ShowName :""}} + </button> </div> </div> </checkbox-group> </view> - <view class="view-bottom" v-if="pageData.OK_Button==true"> - <button type="default" @tap="cancel" - class="btn_cancel">{{translateSys('cancel')}}</button> - <button type="primary" @tap="ok(pageData)" class="btn_add" - :class="pageData.okLoading?'btn_disabled':''" - :disabled="pageData.okLoading? true:false">{{translateSys('ok')}}</button> + <view class="view-bottom" v-if="pageData.Button.length >0 "> + <button v-for="(btn,btnIndex) in pageData.Button" :key="btnIndex" + :type="btn.FunCode == 'Cancel' ? 'default' : 'primary'" + :class="{'btn-disabled':(btn.FunCode != 'Cancel' && pageData.okLoading), + 'btn-one':pageData.Button.length == 1, + 'btn-left':(btnIndex < pageData.Button.length - 1), + 'btn-right': btnIndex > 0 && btnIndex == pageData.Button.length - 1 , + 'width-50':(pageData.Button.length == 2),'width-32':(pageData.Button.length == 3),'width-30':(pageData.DropDownButton.length> 0)}" + :disabled="(btn.FunCode != 'Cancel' && pageData.okLoading)? true:false" + @click="onBtnClick(btn, pageData)"> + <Icon v-if="btn.Style == 'img' || btn.Style == 'img_text'" class="Img" /> + {{(btn.Style == 'text'|| btn.Style == 'img_text') ? btn.ShowName :""}} + </button> + <view class="btn-right" v-if="pageData.DropDownButton.length >0 "> + <a @click="clickDropdownBtns(pageData)"> + <Icon class="mobox-normal-more" /> + </a> + </view> </view> </view> </swiper-item> @@ -194,11 +253,7 @@ pageDetail: [], //{StyleDef{}:,DefList:[],ExtData:{}} // 鍒嗘鍣ㄦ暟鎹� current: 0, - Before_OK_Event: {}, After_OK_Event: {}, - Before_Del_Event: {}, - After_Del_Event: {}, - active_id: '', selectAttrObj: {}, @@ -266,7 +321,6 @@ }); }, async loadData(paramValue) { - //鑾峰彇鏁版嵁绫荤殑鑷畾涔夎〃鍗曞弬鏁� await this.Head_UIStyleGetInfo(this.ClsID, this.param.Input_UI_Style.ID); //浼犲叆鍙傛暟鍊�@@ -309,6 +363,33 @@ this.ClsID, page.UI_Style.ID ); + const buttons = this.pageButtonList(page) + page.Button = buttons + page.DropDownButton = [] + if (buttons.length > 3) { + let cancelBtn = undefined + const btns = [] + buttons.forEach((btn) => { + if (btn.FunCode == "Cancel") { + cancelBtn = btn + } else { + btns.push(btn) + } + }) + if (cancelBtn) { + if (btns.length > 2) { + page.DropDownButton = btns.splice(2) + page.Button = btns + } + page.Button.push(cancelBtn) + } else { + if (btns.length > 3) { + page.DropDownButton = btns.splice(3) + page.Button = btns + } + } + } + page.Row_Button = this.rowButtonList(page) } this.setData({ @@ -323,6 +404,92 @@ current: index }) }, + pageButtonList(page) { + if (this.param?.ver == "2.0") { + return page?.Button || [] + + } else { + if (page?.OK_Button) { + let evt = {}; + if (page.Before_ok?.ID) { + evt = { + ID: page.Before_ok?.ID, + Name: page.Before_ok?.Name + }; + } else if (page.After_ok?.ID) { + evt = { + ID: page.After_ok?.ID, + Name: page.After_ok?.Name + }; + } + let btnCancel = { + Cls_Name: this.param?.master_cls?.name || "", + Cls_ID: this.param?.master_cls?.id || "", + FunCode: "Cancel", + ShowName: this.$t("sys.cancel"), + Style: "text", + Prompt: false, + }; + if (evt.ID) { + let btn = { + Cls_Name: this.param?.master_cls?.name || "", + Cls_ID: this.param?.master_cls?.id || "", + FunCode: "TriggerEvent", + ShowName: this.$t("sys.ok"), + Style: "text", + Prompt: false, + NotTriggerSYSEvent: false, + DataStateVerify: false, + AttrVerify: false, + Event: evt, + }; + if (page.After_ok?.ID) { + btn.After_Event = page.After_ok; + } + return [btn, btnCancel]; + } else return [btnCancel]; + } else { + return []; + } + } + }, + rowButtonList(page) { + if (this.param?.ver == "2.0") { + return page?.Row_Button || []; + } else { + if (page?.Del_Button) { + let evt = {}; + if (page.Before_Delete?.ID) { + evt = { + ID: page.Before_Delete?.ID, + Name: page.Before_Delete?.Name, + }; + } else if (page.After_Delete?.ID) { + evt = { + ID: page.After_Delete?.ID, + Name: page.After_Delete?.Name + }; + } + + if (evt.ID) { + return [{ + Cls_Name: this.param?.master_cls?.name || "", + Cls_ID: this.param?.master_cls?.id || "", + FunCode: "Delete", + ShowName: this.$t("sys.delete"), + Style: "text", + Prompt: false, + NotTriggerSYSEvent: false, + DataStateVerify: false, + AttrVerify: false, + AfterProcess_Event: evt, + }]; + } + } + return []; + } + }, + checkboxChange(e) { var items = this.pageDetail[this.current]?.DefList || [] @@ -363,7 +530,26 @@ await this.DictGetInfo(ele.bind.dict, styledefHead.form.model, ele); + } else { + if (ele?.name === "Select") { + const selections = ele?.selections || [] + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + let itemName = ele.value || ""; + if (itemName) { + styledefHead.form + .model[ele.fieldId] = itemName; + } + ele.dict = selections.map((a) => { + return { + value: a.value, + text: a.label + } + }) + + } + } + if ($this.focusFieldId == "") { if (ele.name == 'Input' || ele.name == 'InputNumber') { @@ -381,6 +567,22 @@ .dict, styledefHead.form .model, col); + } else { + if (col?.name === "Select") { + const selections = col?.selections || [] + //鏈夐粯璁ゅ�锛屾樉绀洪粯璁ゅ� + let itemName = col.value || ""; + if (itemName) { + styledefHead.form + .model[col.fieldId] = itemName; + } + col.dict = selections.map((a) => { + return { + value: a.value, + text: a.label + } + }) + } } if ($this.focusFieldId == "") { if (col.name == 'Input' || col @@ -400,6 +602,8 @@ this.setData({ head_styledef: styledefHead }) + console.log("Head_UIStyleGetInfo", this.head_styledef) + } catch (ex) { // console.log(ex); uni.showModal({ @@ -621,10 +825,67 @@ } }, + onCheckBoxValue(e) { //缁戝畾Model鍊�+ let values = e.detail.value || [] + const item = this.head_styledef.form.items[e.currentTarget?.dataset?.index || 0] + if (item?.setting?.colList) { + const col = item.setting.colList[e.currentTarget?.dataset?.iindex || 0] + if (col) { + col.value = values + let attr = col.fieldId; + this.head_styledef.form.model[attr] = col.value; + var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+ if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+ this.onChange(onChangeEvent); + } + return + } + } else { + if (item) { + item.value = values + let attr = item.fieldId; + this.head_styledef.form.model[attr] = item.value; + var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+ if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+ this.onChange(onChangeEvent); + } + } + } + + }, + onRadioBoxValue(e) { //缁戝畾Model鍊�+ let values = e.detail.value || "" + const item = this.head_styledef.form.items[e.currentTarget?.dataset?.index || 0] + if (item?.setting?.colList) { + const col = item.setting.colList[e.currentTarget?.dataset?.iindex || 0] + if (col) { + col.value = values + let attr = col.fieldId; + this.head_styledef.form.model[attr] = col.value; + var onChangeEvent = col.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+ if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+ this.onChange(onChangeEvent); + } + return + } + } else { + if (item) { + item.value = values + let attr = item.fieldId; + this.head_styledef.form.model[attr] = item.value; + var onChangeEvent = item.bind.onChangeEvent; //鍐呭鍙樺寲鍚庝簨浠�+ if (onChangeEvent.id) { //鍐呭鍙樺寲鍚庝簨浠�+ this.onChange(onChangeEvent); + } + } + + } + + }, classAttr_extButton(item) { var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent; //鍚庡浘鏍囩偣鍑讳簨浠� var onSuffixClickEvent = item.bind.onSuffixClickEvent; //鍚庡浘鏍囩偣鍑诲洖璋�- + if (!onSuffixClickCallbackEvent.id) { uni.showModal({ title: this.translateSys("tip"), @@ -1126,6 +1387,9 @@ number1 = parseInt(value1) if (value2) number2 = parseInt(value2) + if (!operation) { + return value2; + } if (operation == "+") { return number1 + number2 } else if (operation == "-") { @@ -1133,11 +1397,17 @@ } else if (operation == "*") { return number1 * number2 } else if (operation == "/") { - if (number2) - return number1 / number2 - else - return number1 - } else return number2 + if (number2) return number1 / number2; + else { + throw new Error(`${this.translate("illegal_dividend")}'${value2}'`); + return 0; + } + } else if (operation == "=") { + return value2; + } else { + throw new Error(`${this.translate("unrecognized_operator")}'${operation}'`); + return 0; + } }, //鏇存柊鍒嗛〉绛句腑鐨勫垪琛ㄩ」鍐呭 @@ -1153,54 +1423,141 @@ var detailStyleDefList = pageData.DefList || [] detailStyleDefList.forEach(ele => { value.row.forEach((rowData) => { - if (ele.form.objId == rowData.id) { - rowData.attrs.forEach(attr => { - ele.form.items.forEach(ele2 => { - if (ele2.name != - 'Layout') { - if (ele2.fieldId == - attr - .attr) { - ele2.value = - $this - .operationNumber( - ele2 - .value, - attr - .value, - attr - .operation - ) - } - } else if (ele2.name == - 'Layout') { - ele2.setting - .colList - .forEach( - col => { - if ( - col) { - if (col - .fieldId == - attr - .attr - ) { - col.value = - $this - .operationNumber( - col - .value, - attr - .value, - attr - .operation - ) + if (rowData.id) { + if (ele.form.objId == rowData.id) { + rowData.attrs.forEach(attr => { + ele.form.items.forEach(ele2 => { + if (ele2.name != + 'Layout') { + if (ele2.fieldId == + attr + .attr) { + ele2.value = + $this + .operationNumber( + ele2 + .value, + attr + .value, + attr + .operation + ) + } + } else if (ele2.name == + 'Layout') { + ele2.setting + .colList + .forEach( + col => { + if ( + col) { + if (col + .fieldId == + attr + .attr + ) { + col.value = + $this + .operationNumber( + col + .value, + attr + .value, + attr + .operation + ) + } } - } - }) - } + }) + } + }); }); - }); + } + } else if (rowData.condition) { + const conditions = rowData.condition; + let bFindCondition = true; + for (let i in conditions) { + const condition = conditions[i]; + let bFind = false; + for (let i2 in ele.form.items) { + const ele2 = ele.form.items[i2]; + if (ele2.name != "Layout") { + if (ele2.fieldId == condition.attr) { + if (condition.value == ele2.value) { + bFind = true; + } + break; + } + } else { + const colList = ele2.setting.colList || []; + for (let i3 in colList) { + const col = colList[i3]; + if (col.fieldId == condition.attr) { + if (condition.value == col.value) { + bFind = true; + } + break; + } + } + if (bFind) break; + } + } + if (!bFind) { + bFindCondition = false; + break; + } + } + if (bFindCondition) { + + rowData.attrs.forEach(attr => { + ele.form.items.forEach(ele2 => { + if (ele2.name != + 'Layout') { + if (ele2.fieldId == + attr + .attr) { + ele2.value = + $this + .operationNumber( + ele2 + .value, + attr + .value, + attr + .operation + ) + } + } else if (ele2.name == + 'Layout') { + ele2.setting + .colList + .forEach( + col => { + if ( + col) { + if (col + .fieldId == + attr + .attr + ) { + col.value = + $this + .operationNumber( + col + .value, + attr + .value, + attr + .operation + ) + } + } + }) + } + }); + }); + + } } }) }); @@ -1473,21 +1830,6 @@ }, onDetail1EnterChange(item) { //鐮佺洏涓牱寮忓洖杞︿簨浠� console.log(item); - }, - delItem(pageData, index) { //鍒犻櫎鐮佺洏涓牱寮忛潰鏉�- - //鍒犻櫎鐮佺洏涓牱寮忛潰鏉�- this.Before_Del_Event = pageData.Before_Delete; - this.After_Del_Event = pageData.After_Delete; - const style = pageData.DefList[index]; - //鍒犻櫎鐮佺洏涓牱寮忛潰鏉�- pageData.DefList.splice(index, 1); - if (this.Before_Del_Event?.ID) - //鏄惁鏈夊垹闄ゅ墠浜嬩欢 - this.del(pageData, style, this.Before_Del_Event); - else if (this.After_Del_Event?.ID) - //鏄惁鏈夊垹闄ゅ悗浜嬩欢 - this.del(pageData, style, this.After_Del_Event); }, async del(pageData, style, event) { //鑾峰彇琛ㄥご灞炴� @@ -1889,7 +2231,7 @@ }); }, dataObjRunCustomEvent_Return(eventid, data_attr, button_callback, item) { - console.log("dataObjRunCustomEvent_Return",eventid,data_attr,button_callback) + console.log("dataObjRunCustomEvent_Return", eventid, data_attr, button_callback) const $this = this var enviroment = { 'function': '3000', // 鍔熻兘鐐圭紪鍙�@@ -2211,6 +2553,82 @@ onPanelClick(value, id) { // console.log(value); this.active_id = id; + }, + //鐐瑰嚮鎸夐挳鍒楄〃 + clickDropdownBtns(pageData) { + const that = this + const itemlist = []; + const btnList = pageData.DropDownButton || [] + + for (let i in btnList) { + itemlist.push(btnList[i].ShowName || ""); + } + uni.showActionSheet({ + // title: '鎸夐挳鍒楄〃', + itemList: itemlist, + success: (e) => { + console.log(e.tapIndex); + var btn = btnList[e.tapIndex]; + that.onBtnClick(btn, pageData); + } + }) + }, + onBtnClick(btn, pageData) { + if (btn.Prompt) { + const sContent = btn.PromptContent || this.translate("confirm") + uni.showModal({ + title: this.translateSys("tip"), + content: btn.PromptContent || this.translate("confirm"), + success: function(res) { + if (res.confirm) {} + this.onButtonClicked(btn, pageData, -1); + }, + }) + + } else { + this.onButtonClicked(btn, pageData, -1); + } + }, + onRowBtnClick(btn, pageData, index) { + if (btn.Prompt) { + const sContent = btn.PromptContent || this.translate("confirm") + uni.showModal({ + title: this.translateSys("tip"), + content: btn.PromptContent || this.translate("confirm"), + success: function(res) { + if (res.confirm) {} + this.onButtonClicked(btn, pageData, index); + }, + }) + + } else { + this.onButtonClicked(btn, pageData, index); + } + }, + onButtonClicked(btn, pageData, index) { + this.After_OK_Event = {} + let enviroment = { + button: "top", + button_name: btn.ShowName, + cls_id: btn.Cls_ID, + function: "3018", + master: {}, + }; + if (btn.FunCode == "TriggerEvent") { + this.After_OK_Event = btn?.After_Event || {}; + this.sava(pageData, btn.Event); + } else if (btn.FunCode == "Cancel") { + this.cancel(); + } else if (btn.FunCode == "Delete") { + if (index > -1) { + const style = pageData.DefList[index]; + //鍒犻櫎鐮佺洏涓牱寮忛潰鏉�+ pageData.DefList.splice(index, 1); + this.del(pageData, style, btn.AfterProcess_Event); + } + } else { + this.$Message.warning(this.$t("sys.unrealized")); + } }, //纭畾 ok(pageData) { @@ -2814,10 +3232,58 @@ flex-direction: row; width: calc(100% - 30rpx); padding: 10rpx 15rpx 30rpx 15rpx; + + .btn-disabled { + background-color: #ddd; + color: #888; + } + + .btn-left { + padding: 20rpx; + line-height: 1.5; + border: none; + font-size: 38rpx; + font-weight: bold; + float: left; + display: inline-block; + } + + .btn-one { + padding: 20rpx; + line-height: 1.5; + border: none; + font-size: 38rpx; + font-weight: bold; + float: left; + display: inline-block; + width: 50%; + margin-left: 25%; + } + + .btn-right { + padding: 20rpx; + line-height: 1.5; + border: none; + font-size: 38rpx; + font-weight: bold; + float: right; + display: inline-block; + } + + .width-50 { + width: 49%; + } + + .width-32 { + width: 32%; + margin-left: 1%; + } + + .width-30 { + width: 30%; + margin-left: 1%; + } } - - - [nvue] uni-view { position: relative; @@ -2843,7 +3309,7 @@ .dv-panel { background-color: #efefef; - padding: 20rpx 20rpx 4rpx 0px; + padding: 20rpx 20rpx 10rpx 0px; border-radius: 12rpx; margin: 10rpx 0 20rpx 0; text-align: right; @@ -2888,7 +3354,8 @@ .dv-panel-button { width: 100%; text-align: left; - padding-bottom: 20rpx; + min-height: 30rpx; + padding-bottom: 10rpx; checkbox { padding-left: 20px; @@ -2897,44 +3364,12 @@ button { text-align: left; - line-height: 1.8; + line-height: 1.5; border: none; - font-size: 34rpx; - width: 180rpx; + font-size: 30rpx; display: inline-block; float: right; text-align: center; - - .btn_cancel { - width: 49.5%; - padding: 20rpx; - line-height: 1.5; - border: none; - font-size: 38rpx; - font-weight: bold; - float: left; - display: inline-block; - } - - .btn_add { - width: 49.5%; - - padding: 20rpx; - line-height: 1.5; - border: none; - font-size: 38rpx; - font-weight: bold; - float: right; - color: #fff; - display: inline-block; - } - - .btn_disabled { - background-color: #ddd; - color: #888; - } - - } } -- Gitblit v1.9.1