w-ui-v1 1.1.39 → 1.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -19,12 +19,14 @@ import WScanBindingSensor from './w-scan-binding-sensor/w-scan-binding-sensor.vu
19
19
  import WUpdateVersion from './w-update-version/w-update-version.vue'
20
20
  import WTree from './w-tree/w-tree.vue'
21
21
  import WTreeAddTableVue from './w-tree-add-table/w-tree-add-table.vue'
22
+ import WBorrowAddVue from './w-add/w-borrow-add.vue'
22
23
  import {menu} from './utils/apis/menu'
23
24
  import request from './utils/http'
24
25
  import nfc from './utils/nfc'
25
26
  import iData from './utils/idata-scan'
26
27
  import {getPageKey,getDataTotal} from './utils/apis/pageConfig'
27
28
  import { changeLanguage ,changeLanguageConmon} from './Locale'
29
+
28
30
  const coms: any[] = [
29
31
  wTest,
30
32
  wLogin,
@@ -45,7 +47,8 @@ const coms: any[] = [
45
47
  WScanBindingSensor,
46
48
  WUpdateVersion,
47
49
  WTree,
48
- WTreeAddTableVue
50
+ WTreeAddTableVue,
51
+ WBorrowAddVue
49
52
  ]
50
53
  // 批量组件注册
51
54
  function install(Vue: App) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-ui-v1",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "w-ui",
5
5
  "author": "wgxshh",
6
6
  "license": "ISC",
package/utils/http.ts CHANGED
@@ -42,6 +42,10 @@ export default function request(options: any): Promise<any> {
42
42
  uni.reLaunch({ url: '/pages/login/login' })
43
43
  // TODO 401
44
44
  }
45
+ if (res.statusCode === 403) {
46
+ uni.showToast({ title: '权限不足', icon: 'none' })
47
+ // TODO 403
48
+ }
45
49
  if (res.statusCode === 404) {
46
50
  uni.showToast({ title: '请求失败', icon: 'none' })
47
51
  reject(res)
package/w-add/w-add.vue CHANGED
@@ -485,6 +485,21 @@ function addrow(key: any) {
485
485
  })
486
486
 
487
487
  model.value[key].push(t)
488
+
489
+ //开启监听
490
+ uni.$on('addrowSAC',function(data:any){
491
+ console.log(data)
492
+ uni.$off('addrowSAC')
493
+ })
494
+
495
+ uni.navigateTo({
496
+ url:`/pages/add/borrow-add`,
497
+ success() {
498
+ uni.$emit('sendrowSAC',data)
499
+ }
500
+ })
501
+
502
+
488
503
  }
489
504
  //删除一行
490
505
  function remove(key: any, index: any, title: string) {
@@ -0,0 +1,340 @@
1
+
2
+ <template>
3
+ <view>
4
+ <view v-if="loading" style="height: 100px;display: flex;justify-content: center;align-items: center;">
5
+ <wd-loading />
6
+ </view>
7
+ <view v-else>
8
+ <wd-collapse v-model="value">
9
+ <wd-collapse-item custom-body-class="collapse-custom-class" :title="changeLanguageConmon(item.title)" :name="item.id"
10
+ v-for="(item, index) in pageConf.groups" :key="index">
11
+ <view v-if="item.type === 'fieldGroup'">
12
+ <wd-card>
13
+ <wd-form ref="form" :model="model">
14
+ <wd-cell-group v-for="(subItem, subIndex) in item.fields" :key="subIndex">
15
+ <wFromControl :subItem="subItem" :model="model" :Enumcolumn="Enumcolumn"
16
+ v-model:model-value="model[subItem.id]" />
17
+ </wd-cell-group>
18
+
19
+ </wd-form>
20
+ </wd-card>
21
+ </view>
22
+ <view v-if="item.type === 'relation'">
23
+ <view class="row-add">
24
+ <wd-button v-if="item.buttons.includes('selectAdd')" hairline type="info" size="small"
25
+ icon="add" @click="selectrow(item)">{{changeLanguageConmon('选择')}}</wd-button>
26
+ <wd-button v-if="item.buttons.includes('dtmplAdd')" hairline type="info" size="small"
27
+ icon="add" @click="add(item)">{{changeLanguageConmon('新增')}}</wd-button>
28
+ </view>
29
+
30
+ <view v-if="relationLoading[item.id]"
31
+ style="height: 100px;display: flex;justify-content: center;align-items: center;">
32
+ <wd-loading />
33
+ </view>
34
+
35
+ <!-- 卡片 -->
36
+ <view v-else class="card-list">
37
+ <w-card @edit="() => { editItem(item, subitem, subindex) }"
38
+ @delet="() => { deletItem(item, subitem, subindex) }" :actionType="item.type"
39
+ v-for="(subitem, subindex) in selectData[item.id]" :key="subindex" :car-index="subindex"
40
+ :page="{
41
+ rowActions: item.rowActions || [],
42
+ buttons: item.buttons || [],
43
+ ractions: item.ractions || [],
44
+ columns: item.fields || []
45
+ }" :item-data="subitem" :source-id="item.pointSourceId" />
46
+ </view>
47
+
48
+ <view class="row-add" v-if="item.buttons.includes('rowAdd')">
49
+ <wd-button hairline type="info" size="small" icon="add"
50
+ @click="addrow(item.id)">{{changeLanguageConmon('加一条')}}</wd-button>
51
+ </view>
52
+ </view>
53
+ </wd-collapse-item>
54
+ </wd-collapse>
55
+ <view class="footer-button">
56
+ <wd-button :round="false" block @click="handleSubmit" icon="save">{{changeLanguageConmon('保存')}}</wd-button>
57
+ </view>
58
+ </view>
59
+ <wd-message-box />
60
+ <wd-toast />
61
+ </view>
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import { changeLanguageConmon} from '../Locale'
66
+ import wCard from '../w-card/w-card.vue'
67
+ import wFromControl from '../w-form-control/w-form-control.vue'
68
+ import { onLoad, onUnload } from '@dcloudio/uni-app'
69
+ import { ref, defineProps, reactive, watch,onBeforeUpdate } from 'vue';
70
+ import {
71
+ addPageConfig,
72
+ getEnum,
73
+ addPageDataSave,
74
+ getSelectData
75
+ } from '../utils/apis/pageConfig'
76
+ import { useMessage } from 'wot-design-uni'
77
+ import { useToast } from 'wot-design-uni'
78
+ const toast = useToast()
79
+ const message = useMessage()
80
+ defineOptions({
81
+ name: 'w-borrow-add'
82
+ })
83
+
84
+ interface Props {
85
+ sourceId?:string
86
+ mainCode?:string
87
+ }
88
+
89
+ const props = defineProps<Props>()
90
+ const mainCode=ref('')
91
+ const sourceId = ref('')
92
+ const pageConf = ref({ groups: [] })
93
+ const form = ref()//基本数据表单
94
+ //表单数据
95
+ const model = ref({})
96
+ const relationID = ref('')
97
+ const modelsRef = {
98
+
99
+ }
100
+ const relationLoading = reactive({})
101
+ const checkboxvalue = ref([])
102
+ const loading = ref(false)
103
+ const value = ref([])
104
+ const Enumcolumn = ref({})
105
+ const pointSourceId = ref('')
106
+ onLoad((option: any) => {
107
+ sourceId.value = props.sourceId || option.sourceId
108
+ mainCode.value=props.mainCode || option.mainCode
109
+ getPageConfig()
110
+ })
111
+
112
+
113
+ watch(checkboxvalue, (value) => {
114
+
115
+ getSelectDataPxoy(value)
116
+ }, {
117
+ immediate: false,
118
+ deep: true
119
+
120
+ })
121
+
122
+ onBeforeUpdate(()=>{
123
+
124
+ if(props.mainCode){
125
+ mainCode.value=props.mainCode
126
+ }
127
+ if(props.sourceId){
128
+ sourceId.value = props.sourceId
129
+ }
130
+ })
131
+
132
+ onUnload(() => {
133
+ // 取消监听勾选列表页面事件
134
+ uni.$off('getCheckData')
135
+
136
+ })
137
+
138
+ // 获取页面配置
139
+ function getPageConfig() {
140
+
141
+ uni.$on('sendrowSAC',(res:any)=>{
142
+
143
+ console.log(res)
144
+ let data={
145
+ groups:[res]
146
+ }
147
+
148
+ pageConf.value = data
149
+
150
+ let fieldGroup = {}
151
+ let relation = {}
152
+ data.groups.forEach((item: any) => {
153
+ value.value.push(item.id)
154
+ if (item.type === 'relation') {
155
+ let t = []
156
+ relation[item.id] = t
157
+ relationLoading[item.id] = false
158
+ }
159
+
160
+
161
+ if (item.type === 'fieldGroup') {
162
+
163
+ item.fields.forEach((subItem: any) => {
164
+ if (subItem.extControlType === 'datetime') {
165
+ fieldGroup[subItem.id] = null
166
+ return
167
+ }
168
+ fieldGroup[subItem.id] = subItem.defaultValue || ''
169
+
170
+ })
171
+ }
172
+
173
+ })
174
+ model.value = {
175
+ ...relation,
176
+ ...fieldGroup//一般为基本信息
177
+ }
178
+ getEnumer()
179
+ loading.value = false
180
+ })
181
+
182
+
183
+ }
184
+ //获取枚举
185
+ async function getEnumer() {
186
+ let params = []
187
+ pageConf.value.groups?.forEach((item: any) => {
188
+ item.fields?.forEach((subItem: any) => {
189
+ if (subItem.extControlType === 'select') {
190
+ params.push(`mstrucIds=${subItem.mstrucId}`)
191
+ }
192
+ })
193
+ });
194
+ if (!params.length) return
195
+ const res = await getEnum(params.join("&"))
196
+ Enumcolumn.value = res.data?.enumMap || {}
197
+ }
198
+
199
+
200
+ //保存
201
+ async function handleSubmit() {
202
+
203
+ console.log(model)
204
+
205
+ }
206
+
207
+ //跳转勾选页面数据
208
+ function selectrow(item: any) {
209
+ //监听勾选列表页面事件
210
+ uni.$on('getCheckData', function (data: any) {
211
+ checkboxvalue.value = data.checkData
212
+ })
213
+ relationID.value = item.id
214
+ pointSourceId.value = item.pointSourceId
215
+ let data = selectData.value[relationID.value]?.map((item) => {
216
+ return item.code
217
+ })
218
+ uni.navigateTo({
219
+ url: `/pages/selectTable/selectTable?sourceId=${pointSourceId.value}`,
220
+ success: () => {
221
+ uni.$emit('checkeDData', { checkData: data || [] })
222
+ }
223
+ })
224
+ }
225
+ const selectData = ref({})
226
+ //获取勾选数据
227
+ async function getSelectDataPxoy(values: string[]) {
228
+ if (values.length === 0) return model.value[relationID.value] = []
229
+ //获取勾选数据
230
+ let codes = ''
231
+ values.forEach((item: any) => {
232
+ codes += `codes=${item}&`
233
+ })
234
+
235
+ relationLoading[relationID.value] = true
236
+ if (!relationID.value) return
237
+ const res = await getSelectData(relationID.value, codes)
238
+ selectData.value[relationID.value] = res.data.entities
239
+ model.value[relationID.value] = selectData.value[relationID.value].map((item: any) => {
240
+ return item.code
241
+ })
242
+ relationLoading[relationID.value] = false
243
+ }
244
+
245
+ //删除勾选数据
246
+ const deletItem = (item: any, subitem: any, index: any) => {
247
+ relationID.value = item.id
248
+ selectData.value[item.id].splice(index, 1)
249
+ let data = selectData.value[item.id].map((item: any) => {
250
+ return item.code
251
+ })
252
+ checkboxvalue.value = data || []
253
+ }
254
+
255
+ //点击编辑按钮
256
+ const editItem = (item: any, subitem: any, index: any) => {
257
+ relationID.value = item.id
258
+ //监听编辑页面事件
259
+ uni.$on('editeDataSAC', function (data: any) {
260
+
261
+ checkboxvalue.value = selectData.value[item.id]?selectData.value[item.id].map((item: any) => {
262
+ return item.code
263
+ }):[data.entityCode]
264
+ // 取消监听编辑页面事件
265
+ uni.$off('editeDataSAC')
266
+ })
267
+ }
268
+
269
+ //新增按钮
270
+ const add = (item: any) => {
271
+ relationID.value = item.id
272
+ //监听添加数据完成事件
273
+ uni.$on('addDataSAC', function (data: any) {
274
+ checkboxvalue.value = selectData.value[item.id]?[...selectData.value[item.id].map((item: any) => {
275
+ return item.code
276
+ }), data.entityCode]:[data.entityCode]
277
+ // 取消监听添加数据完成事件
278
+ uni.$off('addDataSAC')
279
+ })
280
+ //跳转新增页面
281
+ uni.navigateTo({
282
+ url: `/pages/add/add?sourceId=${item.pointSourceId}`,
283
+ })
284
+ }
285
+
286
+
287
+ //新加一行
288
+ function addrow(key: any) {
289
+
290
+ let data = pageConf.value.groups.find((item: any) => {
291
+ return item.id === key
292
+ })
293
+ let t = {}
294
+ data.fields.forEach((subItem: any) => {
295
+ t[subItem.id] = subItem.defaultValue || ''
296
+ })
297
+
298
+ model.value[key].push(t)
299
+ }
300
+ //删除一行
301
+ function remove(key: any, index: any, title: string) {
302
+ message
303
+ .confirm({
304
+ msg: changeLanguageConmon(`${title}--确定删除第${index + 1}条数据吗?`),
305
+ title: changeLanguageConmon('删除')
306
+ })
307
+ .then(() => {
308
+ model.value[key].splice(index, 1)
309
+ })
310
+ .catch(() => {
311
+ console.log('点击了取消按钮')
312
+ })
313
+
314
+ }
315
+ </script>
316
+
317
+ <style scoped lang="scss">
318
+ .footer-button {
319
+ width: 100%;
320
+ box-sizing: border-box;
321
+ padding: 5px 10px 5px 10px;
322
+ position: sticky;
323
+ bottom: 0;
324
+ background-color: #fff;
325
+
326
+ }
327
+
328
+ .row-add {
329
+ // background-color: #fff;
330
+ padding: 0 0 8px 0;
331
+ display: flex;
332
+ justify-content: center;
333
+ gap: 5px;
334
+ }
335
+
336
+ :deep(.collapse-custom-class) {
337
+ background-color: #f8f8f8;
338
+ padding: 15px 0 0.5px 0 !important;
339
+ }
340
+ </style>
@@ -94,6 +94,15 @@
94
94
  @clear="clear" clearable />
95
95
  </view>
96
96
  </wd-cell>
97
+ <wd-cell v-else-if="subItem.extControlType === 'table-entity-select'" title-width="100px" :prop="subItem.id"
98
+ :rules="[{ required: subItem.required, message: `${changeLanguageConmon('请选择')}${changeLanguageConmon(subItem.title)}` }]" :title="changeLanguageConmon(subItem.title)">
99
+ <view style="text-align: left">
100
+ <wSelectPicker @confirm="wSelectPickerconfirm" :modelValue="modelValue" :disabled="subItem.disabled"
101
+ :max="subItem.max==='1'?1:0"
102
+ :placeholder="subItem.disabled ? changeLanguageConmon('无需输入') : `${changeLanguageConmon('请输入')}${changeLanguageConmon(subItem.title)}`" :source-id="subItem.sourceId" filterable
103
+ @clear="clear" clearable />
104
+ </view>
105
+ </wd-cell>
97
106
 
98
107
  <wd-cell v-else-if="subItem.extControlType === 'file'||subItem.extControlType === 'picture'"
99
108
  :rules="[{ required: subItem.required, message: `${changeLanguageConmon('请选择')}${changeLanguageConmon(subItem.title)}文件` }]" :title="subItem.title"
@@ -235,6 +244,20 @@ const modelValue = computed(() => {
235
244
 
236
245
  }
237
246
 
247
+
248
+ if(props.subItem.extControlType === 'table-entity-select'){
249
+ if(props.model[props.subItem.id]){
250
+ let dataArr1=props.model[props.subItem.id].split('@,@')
251
+ let dataArr2=dataArr1.map((item:any)=>{
252
+ return item.split("@R@")[0]
253
+ })
254
+ return dataArr2
255
+ }else{
256
+ return[]
257
+ }
258
+
259
+ }
260
+
238
261
  if(props.subItem.extControlType === 'file'){
239
262
  return props.model[props.subItem.id]?[JSON.parse(props.model[props.subItem.id])['base']]:[]
240
263
  }
package/w-tree/w-tree.vue CHANGED
@@ -112,7 +112,7 @@
112
112
  if(selectedItems.length>1){
113
113
  return selectedItems[selectedItems.length - 2].label + '/' + selectedItems[selectedItems.length - 1].label
114
114
  }else{
115
- return selectedItems[selectedItems.length - 1].label
115
+ return selectedItems[selectedItems.length - 1]?.label
116
116
  }
117
117
  }
118
118
  </script>
@@ -3,9 +3,9 @@
3
3
  <w-tree :handleConfirm="handleConfirm" @handleConfirm="handleConfirm"></w-tree>
4
4
  <w-add :mainCode="mainCode" :sourceId="sourceId"></w-add>
5
5
  </view>
6
-
7
- </template>
8
-
6
+
7
+ </template>
8
+
9
9
  <script lang="ts" setup>
10
10
  import wTree from '../w-tree/w-tree.vue'
11
11
  import wAdd from '../w-add/w-add.vue'
@@ -18,8 +18,8 @@
18
18
  const handleConfirm=(data:any)=>{
19
19
  mainCode.value=data.data.value[data.data.value.length-1]
20
20
  sourceId.value=data.leafRatmplId
21
- }
22
- </script>
23
-
24
- <style>
21
+ }
22
+ </script>
23
+
24
+ <style>
25
25
  </style>