cnhis-design-vue 3.1.1 → 3.1.2

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.
@@ -110,12 +110,11 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
110
110
  return params.row[item.formatMap.label]
111
111
  }
112
112
  if (item.options) {
113
- return item.options.find((v: any) => v.value == value)?.label || ''
113
+ return item.options.find((v: any) => v.value == value)?.label || value || ''
114
114
  }
115
115
  if (item.queryOptions) {
116
- return (params.row[`${item.columnName}_options`]?.find((v: any) => v.value === value)?.label) || ''
116
+ return (params.row[`${item.columnName}_options`]?.find((v: any) => v.value === value)?.label) || value || ''
117
117
  }
118
- return value
119
118
  }
120
119
  return value
121
120
  }
@@ -1,35 +1,34 @@
1
1
  <template>
2
- <span @click="handleClickWrap">
3
- <NDropdown
4
- class="rowFoldHideBtnList-dropdown"
5
- placement="bottom-start"
6
- :show="state.visible"
7
- @clickoutside="handleClickOutside"
8
- :options="options"
9
- @select="handleSelect"
10
- :render-label="renderLabel"
2
+ <n-dropdown
3
+ class="rowFoldHideBtnList-dropdown"
4
+ placement="bottom-start"
5
+ trigger="click"
6
+ :show="state.visible"
7
+ @clickoutside="handleClickOutside"
8
+ :options="options"
9
+ @select="handleSelect"
10
+ :render-label="renderLabel"
11
+ >
12
+ <slot
13
+ name="button"
14
+ :handleClickPrintBtn="handleClickBtn"
15
+ :printSpinning="state.spinning"
16
+ :printbtnText="btnText"
17
+ :printVisible="state.visible"
11
18
  >
12
- <slot
13
- name="button"
14
- :handleClickPrintBtn="handleClickBtn"
15
- :printSpinning="state.spinning"
16
- :printbtnText="btnText"
17
- :printVisible="state.visible"
18
- >
19
- <NButton class="dropdown-button" style="margin: 0 8px 8px 0" @click.stop="handleClickBtn">
20
- <NIcon v-if="state.spinning" :component="Reload" style="line-height: 10px" />
21
- {{ btnText }}
22
- <NIcon :component="ChevronDown" />
23
- </NButton>
24
- </slot>
25
- </NDropdown>
19
+ <n-button class="dropdown-button" style="margin: 0 8px 8px 0" @click.stop="handleClickBtn">
20
+ <!-- <n-spin v-show="state.spinning" size="small"></n-spin> -->
21
+ {{ btnText }}
22
+ <n-icon :component="ChevronDown" />
23
+ </n-button>
24
+ </slot>
25
+ </n-dropdown>
26
26
 
27
- <IdentityVerification
28
- v-model="state.identityVerification.visible"
29
- v-bind="$attrs"
30
- @success="verifiySuccess"
31
- ></IdentityVerification>
32
- </span>
27
+ <IdentityVerification
28
+ v-model="state.identityVerification.visible"
29
+ v-bind="$attrs"
30
+ @success="verifiySuccess"
31
+ ></IdentityVerification>
33
32
  </template>
34
33
 
35
34
  <script lang="tsx">
@@ -41,7 +40,7 @@ export default create({
41
40
 
42
41
  <script setup lang="tsx">
43
42
  import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue'
44
- import { NDropdown, NButton, NIcon } from 'naive-ui'
43
+ import { NDropdown, NButton, NIcon, NSpin } from 'naive-ui'
45
44
  import { ChevronDown, Reload } from "@vicons/ionicons5";
46
45
  import { useMessage } from 'naive-ui'
47
46
  import type { DropdownOption } from 'naive-ui'
@@ -53,7 +52,6 @@ import moment from 'moment';
53
52
  (window as any).$message = useMessage()
54
53
  let printInstance: any = null;
55
54
 
56
- // 在.vue文件中使用导入的interface会报错,提示要使用字面量类型,当前在github上vue的issue已经有这个问题了,目前还没解决
57
55
  interface Props {
58
56
  btnText?: string
59
57
  printText?: string
@@ -67,6 +65,8 @@ interface Props {
67
65
  queryTemplateParams?: Function
68
66
  strategy?: string
69
67
  printParams?: any[]
68
+ clickPrevFn?: Function,
69
+ noDataMsg?: string
70
70
  }
71
71
  const props = withDefaults(defineProps<Props>(), {
72
72
  params: () => ([]),
@@ -80,8 +80,10 @@ const props = withDefaults(defineProps<Props>(), {
80
80
  queryPrintFormatByNumber: () => Promise.resolve({}),
81
81
  queryTemplateParams: () => Promise.resolve({}),
82
82
  strategy: 'MULTI',
83
+ clickPrevFn: () => Promise.resolve(true),
84
+ noDataMsg: '请选中需要打印的数据'
83
85
  });
84
- const emit = defineEmits(['success', 'error']);
86
+ const emit = defineEmits(['success', 'error', 'clickoutside']);
85
87
 
86
88
  const state = reactive({
87
89
  spinning: false,
@@ -277,16 +279,7 @@ const handleSelect = (key: string) => {
277
279
  }
278
280
  const handleClickOutside = () => {
279
281
  state.visible = false;
280
- }
281
- const handleClickWrap = () => {
282
- setTimeout(() => {
283
- state.visible = true;
284
- }, 0);
285
- }
286
- const setTimeoutSpin = () => {
287
- (state as any).spinTimer = setTimeout(() => {
288
- state.spinning = true;
289
- }, 1500);
282
+ emit('clickoutside')
290
283
  }
291
284
  const instantiatePrintSDK = () => {
292
285
  if (printInstance) return false;
@@ -320,15 +313,9 @@ const formatFormatList = (list: any[]): any => {
320
313
 
321
314
  return formatList;
322
315
  }
323
- const setLoaded = () => {
324
- state.spinning = false;
325
- if (!state.spinTimer) return false;
326
- clearTimeout(state.spinTimer);
327
- state.spinTimer = null;
328
- }
329
316
  const requestError = () => {
330
317
  state.isInited = false;
331
- setLoaded();
318
+ state.spinning = false;
332
319
  setTimeout(() => {
333
320
  state.visible = false;
334
321
  }, 0);
@@ -405,17 +392,23 @@ const init = async () => {
405
392
  if (state.isInited) return true;
406
393
  state.isInited = true;
407
394
 
408
- setTimeoutSpin();
395
+ state.spinning = true;
409
396
 
410
397
  instantiatePrintSDK();
411
398
  const formatListResult = await props.queryPrintFormatByNumber()
412
399
  await initCRM(formatListResult);
413
400
 
414
- setLoaded();
401
+ state.spinning = false;
415
402
 
416
403
  return true;
417
404
  }
418
405
  const handleClickBtn = async () => {
406
+ const status = await props.clickPrevFn()
407
+ if (!status) return
408
+ if (!props.params?.length) {
409
+ (window as any).$message.warning(props.noDataMsg)
410
+ return
411
+ }
419
412
  if (!state.visible) {
420
413
  let result = await init();
421
414
  if (!result) return false;
@@ -6,11 +6,11 @@
6
6
  :show="modelValue"
7
7
  :close-on-esc="false"
8
8
  :show-icon="false"
9
- :style="{ width: style.width, maxHeight: style.height, overflowY: 'auto' }"
10
- @after-leave="handleClickClose"
9
+ :style="{ width: style.width, overflowY: 'auto' }"
10
+ @close="handleClickClose"
11
11
  >
12
12
  <div class="content">
13
- <NForm class="login-form" ref="formRef" :model="form" :rules="rules">
13
+ <NForm class="login-form-button-print" ref="formRef" :model="form" :rules="rules">
14
14
  <NFormItem path="account">
15
15
  <NInput v-model:value="form.account" placeholder="请输入账号" />
16
16
  </NFormItem>
@@ -61,7 +61,7 @@ const rules: FormRules = {
61
61
  }
62
62
  const style = {
63
63
  width: '416px',
64
- height: '328px'
64
+ // height: '328px'
65
65
  }
66
66
  const formRef = ref<FormInst | null>(null)
67
67
 
@@ -99,22 +99,23 @@ watch(() => props.modelValue,
99
99
 
100
100
  </script>
101
101
  <style lang="less" scoped>
102
- .login-form {
103
- padding-top: 15px;
104
- &:deep(.n-input) {
105
- height: 50px;
106
- font-size: 14px;
107
- color: #757575;
108
- border-radius: 6px;
109
- }
110
- }
111
102
  .login-form-button {
112
103
  width: 100%;
113
104
  height: 50px;
114
- background: #2d7aff;
115
105
  border-radius: 24px;
116
- border-color: #2d7aff !important;
117
106
  font-size: 16px;
118
107
  color: #ffffff;
119
108
  }
120
109
  </style>
110
+ <style lang="less">
111
+ .login-form-button-print {
112
+ padding-top: 15px;
113
+ .n-input {
114
+ height: 50px;
115
+ line-height: 50px;
116
+ font-size: 14px;
117
+ color: #757575;
118
+ border-radius: 6px;
119
+ }
120
+ }
121
+ </style>