cnhis-design-vue 3.0.9 → 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.
@@ -1,6 +1,6 @@
1
- import { defineComponent, reactive, ref, onMounted, watch, openBlock, createBlock, unref, normalizeStyle, withCtx, createElementVNode, createVNode, createTextVNode, computed, createElementBlock, renderSlot, withModifiers, createCommentVNode, toDisplayString, mergeProps } from 'vue';
1
+ import { defineComponent, reactive, ref, onMounted, watch, openBlock, createBlock, unref, normalizeStyle, withCtx, createElementVNode, createVNode, createTextVNode, computed, createElementBlock, Fragment, renderSlot, withModifiers, createCommentVNode, toDisplayString, mergeProps } from 'vue';
2
2
  import { useMessage, NModal, NForm, NFormItem, NInput, NButton, NDropdown, NIcon } from 'naive-ui';
3
- import { Reload, ChevronDown } from '@vicons/ionicons5';
3
+ import { ChevronDown } from '@vicons/ionicons5';
4
4
 
5
5
  function t(t2, e2, r2, n2, o2, i2, a2) {
6
6
  try {
@@ -2107,8 +2107,7 @@ var script$1 = /* @__PURE__ */ defineComponent({
2107
2107
  password: { required: true, message: "\u8BF7\u8F93\u5165\u5BC6\u7801" }
2108
2108
  };
2109
2109
  const style = {
2110
- width: "416px",
2111
- height: "328px"
2110
+ width: "416px"
2112
2111
  };
2113
2112
  const formRef = ref(null);
2114
2113
  const handleClickClose = () => {
@@ -2148,13 +2147,13 @@ var script$1 = /* @__PURE__ */ defineComponent({
2148
2147
  show: __props.modelValue,
2149
2148
  "close-on-esc": false,
2150
2149
  "show-icon": false,
2151
- style: normalizeStyle({ width: style.width, maxHeight: style.height, overflowY: "auto" }),
2152
- onAfterLeave: handleClickClose
2150
+ style: normalizeStyle({ width: style.width, overflowY: "auto" }),
2151
+ onClose: handleClickClose
2153
2152
  }, {
2154
2153
  default: withCtx(() => [
2155
2154
  createElementVNode("div", _hoisted_1, [
2156
2155
  createVNode(unref(NForm), {
2157
- class: "login-form",
2156
+ class: "login-form-button-print",
2158
2157
  ref_key: "formRef",
2159
2158
  ref: formRef,
2160
2159
  model: unref(form),
@@ -7898,20 +7897,77 @@ const __default__ = create({
7898
7897
  var script = /* @__PURE__ */ defineComponent({
7899
7898
  ...__default__,
7900
7899
  props: {
7901
- btnText: { type: String, required: false, default: "\u6253\u5370" },
7902
- printText: { type: String, required: false, default: "\u76F4\u63A5\u6253\u5370" },
7903
- previewText: { type: String, required: false, default: "\u6253\u5370\u9884\u89C8" },
7904
- formatEditText: { type: String, required: false, default: "\u683C\u5F0F\u7F16\u8F91" },
7905
- identityVerificationTitle: { type: String, required: false, default: "\u6253\u5370\u670D\u52A1\u8EAB\u4EFD\u6821\u9A8C" },
7906
- params: { type: Array, required: false, default: () => [] },
7907
- prevFn: { type: Function, required: false, default: () => Promise.resolve() },
7908
- verifyUser: { type: Function, required: false, default: () => Promise.resolve() },
7909
- queryPrintFormatByNumber: { type: Function, required: true, default: () => Promise.resolve({}) },
7910
- queryTemplateParams: { type: Function, required: false, default: () => Promise.resolve({}) },
7911
- strategy: { type: String, required: false, default: "MULTI" },
7912
- printParams: { type: Array, required: false }
7900
+ btnText: {
7901
+ type: String,
7902
+ required: false,
7903
+ default: "\u6253\u5370"
7904
+ },
7905
+ printText: {
7906
+ type: String,
7907
+ required: false,
7908
+ default: "\u76F4\u63A5\u6253\u5370"
7909
+ },
7910
+ previewText: {
7911
+ type: String,
7912
+ required: false,
7913
+ default: "\u6253\u5370\u9884\u89C8"
7914
+ },
7915
+ formatEditText: {
7916
+ type: String,
7917
+ required: false,
7918
+ default: "\u683C\u5F0F\u7F16\u8F91"
7919
+ },
7920
+ identityVerificationTitle: {
7921
+ type: String,
7922
+ required: false,
7923
+ default: "\u6253\u5370\u670D\u52A1\u8EAB\u4EFD\u6821\u9A8C"
7924
+ },
7925
+ params: {
7926
+ type: Array,
7927
+ required: false,
7928
+ default: () => []
7929
+ },
7930
+ prevFn: {
7931
+ type: Function,
7932
+ required: false,
7933
+ default: () => Promise.resolve()
7934
+ },
7935
+ verifyUser: {
7936
+ type: Function,
7937
+ required: false,
7938
+ default: () => Promise.resolve()
7939
+ },
7940
+ queryPrintFormatByNumber: {
7941
+ type: Function,
7942
+ required: true,
7943
+ default: () => Promise.resolve({})
7944
+ },
7945
+ queryTemplateParams: {
7946
+ type: Function,
7947
+ required: false,
7948
+ default: () => Promise.resolve({})
7949
+ },
7950
+ strategy: {
7951
+ type: String,
7952
+ required: false,
7953
+ default: "MULTI"
7954
+ },
7955
+ printParams: {
7956
+ type: Array,
7957
+ required: false
7958
+ },
7959
+ clickPrevFn: {
7960
+ type: Function,
7961
+ required: false,
7962
+ default: () => Promise.resolve(true)
7963
+ },
7964
+ noDataMsg: {
7965
+ type: String,
7966
+ required: false,
7967
+ default: "\u8BF7\u9009\u4E2D\u9700\u8981\u6253\u5370\u7684\u6570\u636E"
7968
+ }
7913
7969
  },
7914
- emits: ["success", "error"],
7970
+ emits: ["success", "error", "clickoutside"],
7915
7971
  setup(__props, { emit }) {
7916
7972
  const props = __props;
7917
7973
  window.$message = useMessage();
@@ -7930,27 +7986,30 @@ var script = /* @__PURE__ */ defineComponent({
7930
7986
  watchPrintParamsReformatFn: null,
7931
7987
  spinTimer: null
7932
7988
  });
7933
- const options = reactive([
7934
- {
7989
+ const options = reactive([{
7935
7990
  label: props.printText,
7936
7991
  key: "printText"
7937
- },
7938
- {
7992
+ }, {
7939
7993
  label: props.previewText,
7940
7994
  key: "previewText"
7941
- },
7942
- {
7995
+ }, {
7943
7996
  label: props.formatEditText,
7944
7997
  key: "formatEditText"
7945
- }
7946
- ]);
7998
+ }]);
7947
7999
  const currentFormatItem = computed(() => {
7948
8000
  if (!state.currentFormatId)
7949
8001
  return {};
7950
8002
  let id = state.currentFormatId;
7951
8003
  return state.formatList.find((item) => item.id === id);
7952
8004
  });
7953
- computed(() => currentFormatItem.value.name || "\u683C\u5F0F\u9009\u62E9");
8005
+ const formatTitle = computed(() => currentFormatItem.value.name || "\u683C\u5F0F\u9009\u62E9");
8006
+ const renderLabel = (option) => {
8007
+ return createVNode("span", {
8008
+ "class": {
8009
+ "active": option.key === state.currentFormatId
8010
+ }
8011
+ }, [option.label]);
8012
+ };
7954
8013
  const getTemplateIdByFormatId = (id) => {
7955
8014
  let find = state.formatList.find((item) => item.id === id);
7956
8015
  return find.templateId;
@@ -8080,21 +8139,13 @@ var script = /* @__PURE__ */ defineComponent({
8080
8139
  break;
8081
8140
  default:
8082
8141
  state.currentFormatId = key;
8142
+ state.visible = false;
8083
8143
  break;
8084
8144
  }
8085
8145
  };
8086
8146
  const handleClickOutside = () => {
8087
8147
  state.visible = false;
8088
- };
8089
- const handleClickWrap = () => {
8090
- setTimeout(() => {
8091
- state.visible = true;
8092
- }, 0);
8093
- };
8094
- const setTimeoutSpin = () => {
8095
- state.spinTimer = setTimeout(() => {
8096
- state.spinning = true;
8097
- }, 1500);
8148
+ emit("clickoutside");
8098
8149
  };
8099
8150
  const instantiatePrintSDK = () => {
8100
8151
  if (printInstance)
@@ -8107,6 +8158,19 @@ var script = /* @__PURE__ */ defineComponent({
8107
8158
  let findDefault = list.find((item) => item[key] == 1);
8108
8159
  return findDefault?.id || list[0].id;
8109
8160
  };
8161
+ const setOptions = () => {
8162
+ const children = state.formatList.map((v) => {
8163
+ return {
8164
+ label: v.name,
8165
+ key: v.id
8166
+ };
8167
+ });
8168
+ options.unshift({
8169
+ label: formatTitle.value,
8170
+ key: "format",
8171
+ children
8172
+ });
8173
+ };
8110
8174
  const formatFormatList = (list) => {
8111
8175
  let formatList = [];
8112
8176
  list.forEach((item) => {
@@ -8116,16 +8180,9 @@ var script = /* @__PURE__ */ defineComponent({
8116
8180
  });
8117
8181
  return formatList;
8118
8182
  };
8119
- const setLoaded = () => {
8120
- state.spinning = false;
8121
- if (!state.spinTimer)
8122
- return false;
8123
- clearTimeout(state.spinTimer);
8124
- state.spinTimer = null;
8125
- };
8126
8183
  const requestError = () => {
8127
8184
  state.isInited = false;
8128
- setLoaded();
8185
+ state.spinning = false;
8129
8186
  setTimeout(() => {
8130
8187
  state.visible = false;
8131
8188
  }, 0);
@@ -8172,6 +8229,7 @@ var script = /* @__PURE__ */ defineComponent({
8172
8229
  state.formatList = formatListResult ? formatFormatList(formatListResult.obj) : [];
8173
8230
  console.log("formatListResult", formatListResult);
8174
8231
  state.currentFormatId = getDefaultFormatId(state.formatList, "defaultFlag");
8232
+ setOptions();
8175
8233
  if (!state.currentFormatId) {
8176
8234
  window.$message.error("\u83B7\u53D6\u6253\u5370\u683C\u5F0F\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01");
8177
8235
  return requestError();
@@ -8193,14 +8251,21 @@ var script = /* @__PURE__ */ defineComponent({
8193
8251
  if (state.isInited)
8194
8252
  return true;
8195
8253
  state.isInited = true;
8196
- setTimeoutSpin();
8254
+ state.spinning = true;
8197
8255
  instantiatePrintSDK();
8198
8256
  const formatListResult = await props.queryPrintFormatByNumber();
8199
8257
  await initCRM(formatListResult);
8200
- setLoaded();
8258
+ state.spinning = false;
8201
8259
  return true;
8202
8260
  };
8203
8261
  const handleClickBtn = async () => {
8262
+ const status = await props.clickPrevFn();
8263
+ if (!status)
8264
+ return;
8265
+ if (!props.params?.length) {
8266
+ window.$message.warning(props.noDataMsg);
8267
+ return;
8268
+ }
8204
8269
  if (!state.visible) {
8205
8270
  let result = await init();
8206
8271
  if (!result)
@@ -8239,48 +8304,44 @@ var script = /* @__PURE__ */ defineComponent({
8239
8304
  if (!val?.length)
8240
8305
  return false;
8241
8306
  reformatPrintParams();
8242
- }, { deep: true });
8307
+ }, {
8308
+ deep: true
8309
+ });
8243
8310
  return (_ctx, _cache) => {
8244
- return openBlock(), createElementBlock("span", { onClick: handleClickWrap }, [
8245
- createVNode(unref(NDropdown), {
8311
+ return openBlock(), createElementBlock(Fragment, null, [createVNode(unref(NDropdown), {
8312
+ class: "rowFoldHideBtnList-dropdown",
8246
8313
  placement: "bottom-start",
8314
+ trigger: "click",
8247
8315
  show: unref(state).visible,
8248
8316
  onClickoutside: handleClickOutside,
8249
8317
  options: unref(options),
8250
- onSelect: handleSelect
8318
+ onSelect: handleSelect,
8319
+ "render-label": renderLabel
8251
8320
  }, {
8252
- default: withCtx(() => [
8253
- renderSlot(_ctx.$slots, "button", {
8321
+ default: withCtx(() => [renderSlot(_ctx.$slots, "button", {
8254
8322
  handleClickPrintBtn: handleClickBtn,
8255
8323
  printSpinning: unref(state).spinning,
8256
8324
  printbtnText: __props.btnText,
8257
8325
  printVisible: unref(state).visible
8258
- }, () => [
8259
- createVNode(unref(NButton), {
8326
+ }, () => [createVNode(unref(NButton), {
8260
8327
  class: "dropdown-button",
8261
- style: { "margin": "0 8px 8px 0" },
8328
+ style: {
8329
+ "margin": "0 8px 8px 0"
8330
+ },
8262
8331
  onClick: withModifiers(handleClickBtn, ["stop"])
8263
8332
  }, {
8264
- default: withCtx(() => [
8265
- unref(state).spinning ? (openBlock(), createBlock(unref(NIcon), {
8266
- key: 0,
8267
- component: unref(Reload),
8268
- style: { "line-height": "10px" }
8269
- }, null, 8, ["component"])) : createCommentVNode("v-if", true),
8270
- createTextVNode(" " + toDisplayString(__props.btnText) + " ", 1),
8271
- createVNode(unref(NIcon), { component: unref(ChevronDown) }, null, 8, ["component"])
8272
- ]),
8333
+ default: withCtx(() => [createCommentVNode(' <n-spin v-show="state.spinning" size="small"></n-spin> '), createTextVNode(toDisplayString(__props.btnText) + " ", 1), createVNode(unref(NIcon), {
8334
+ component: unref(ChevronDown)
8335
+ }, null, 8, ["component"])]),
8273
8336
  _: 1
8274
- }, 8, ["onClick"])
8275
- ])
8276
- ]),
8337
+ }, 8, ["onClick"])])]),
8277
8338
  _: 3
8278
- }, 8, ["show", "options"]),
8279
- createVNode(script$1, mergeProps({
8339
+ }, 8, ["show", "options"]), createVNode(script$1, mergeProps({
8280
8340
  modelValue: unref(state).identityVerification.visible,
8281
8341
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(state).identityVerification.visible = $event)
8282
- }, _ctx.$attrs, { onSuccess: verifiySuccess }), null, 16, ["modelValue"])
8283
- ]);
8342
+ }, _ctx.$attrs, {
8343
+ onSuccess: verifiySuccess
8344
+ }), null, 16, ["modelValue"])], 64);
8284
8345
  };
8285
8346
  }
8286
8347
  });