@kmkf-fe-packages/basic-components 0.2.2-alpha.0 → 0.2.2-alpha.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.
@@ -14,6 +14,7 @@ interface LogisticsInterceptionProps {
14
14
  logisticsOptions: any[];
15
15
  required: boolean;
16
16
  disabled: boolean;
17
+ isEditing: boolean;
17
18
  id: string;
18
19
  onChange: (value: Partial<LogisticsInterceptionValueType>) => void;
19
20
  }
package/dist/index.esm.js CHANGED
@@ -3122,9 +3122,13 @@ var LogisticsInterception = function LogisticsInterception(props) {
3122
3122
  value = _props$value === void 0 ? {} : _props$value,
3123
3123
  _props$logisticsOptio = props.logisticsOptions,
3124
3124
  logisticsOptions = _props$logisticsOptio === void 0 ? [] : _props$logisticsOptio,
3125
- required = props.required,
3125
+ _props$required = props.required,
3126
+ required = _props$required === void 0 ? false : _props$required,
3126
3127
  onChange = props.onChange,
3127
- disabled = props.disabled;
3128
+ _props$disabled = props.disabled,
3129
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
3130
+ _props$isEditing = props.isEditing,
3131
+ isEditing = _props$isEditing === void 0 ? false : _props$isEditing;
3128
3132
  var _useState = useState([]),
3129
3133
  _useState2 = _slicedToArray(_useState, 2),
3130
3134
  typeOptions = _useState2[0],
@@ -3133,40 +3137,54 @@ var LogisticsInterception = function LogisticsInterception(props) {
3133
3137
  _useState4 = _slicedToArray(_useState3, 2),
3134
3138
  statusOptions = _useState4[0],
3135
3139
  setStatusOptions = _useState4[1];
3136
- var _useState5 = useState(true),
3140
+ var _useState5 = useState(false),
3137
3141
  _useState6 = _slicedToArray(_useState5, 2),
3138
3142
  isInterface = _useState6[0],
3139
3143
  setIsInterface = _useState6[1];
3144
+ var canEdit = useMemo(function () {
3145
+ //非对接公司可以修改
3146
+ if (!isInterface) return true;
3147
+ //已对接公司在拦截中可以修改
3148
+ var INTERCEPTING = statusOptions.some(function (item) {
3149
+ return item.value === (value === null || value === void 0 ? void 0 : value.interceptStatus) && (item === null || item === void 0 ? void 0 : item.showInterceptionBtn);
3150
+ });
3151
+ return isEditing && (value === null || value === void 0 ? void 0 : value.interceptStatus) ? INTERCEPTING && isEditing : true;
3152
+ }, [value, statusOptions, isInterface, isEditing]);
3140
3153
  useEffect(function () {
3141
- onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2(_objectSpread2({}, value), {}, {
3142
- interceptType: undefined,
3143
- interceptAddress: [],
3144
- interceptDetail: '',
3145
- interceptReceiverName: '',
3146
- interceptReceiverMobile: '',
3147
- interceptStatus: '',
3148
- interceptOther: ''
3149
- }));
3150
3154
  if (!(value === null || value === void 0 ? void 0 : value.interceptCompany)) {
3151
3155
  setTypeOptions([]);
3152
3156
  setStatusOptions([]);
3153
- setIsInterface(true);
3157
+ setIsInterface(false);
3154
3158
  return;
3155
3159
  }
3156
3160
  var interceptCompany = logisticsOptions.find(function (item) {
3157
3161
  return item.expressCode === (value === null || value === void 0 ? void 0 : value.interceptCompany);
3158
3162
  });
3159
3163
  setTypeOptions((interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.interceptionTypeList) || []);
3164
+ setStatusOptions((interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.interceptionStatusList) || []);
3160
3165
  setIsInterface(interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.isInterface);
3161
3166
  }, [value === null || value === void 0 ? void 0 : value.interceptCompany]);
3167
+ //是否展示新地址
3162
3168
  var showNewAddress = useMemo(function () {
3163
3169
  var _find, _find$config;
3164
3170
  return (_find = (typeOptions || []).find(function (item) {
3165
3171
  return item.value === (value === null || value === void 0 ? void 0 : value.interceptType);
3166
3172
  })) === null || _find === void 0 ? void 0 : (_find$config = _find.config) === null || _find$config === void 0 ? void 0 : _find$config.showAddress;
3167
- }, [value === null || value === void 0 ? void 0 : value.interceptType]);
3173
+ }, [value === null || value === void 0 ? void 0 : value.interceptType, typeOptions, value === null || value === void 0 ? void 0 : value.interceptCompany]);
3168
3174
  var changeHandle = function changeHandle(val, type) {
3169
3175
  var newValue = _objectSpread2(_objectSpread2({}, value), {}, _defineProperty({}, type, val));
3176
+ if (type === 'interceptCompany') {
3177
+ newValue = _objectSpread2(_objectSpread2({}, value), {}, {
3178
+ interceptCompany: val,
3179
+ interceptType: 'RETURN',
3180
+ interceptAddress: [],
3181
+ interceptDetail: '',
3182
+ interceptReceiverName: '',
3183
+ interceptReceiverMobile: '',
3184
+ interceptStatus: '',
3185
+ interceptOther: ''
3186
+ });
3187
+ }
3170
3188
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
3171
3189
  };
3172
3190
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Item, {
@@ -3174,11 +3192,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3174
3192
  required: required,
3175
3193
  key: 'logistics'
3176
3194
  }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Select, {
3177
- disabled: disabled,
3178
- fieldNames: {
3179
- label: 'expressName',
3180
- value: 'expressCode'
3181
- },
3195
+ disabled: disabled || !canEdit,
3182
3196
  placeholder: "\u7269\u6D41\u516C\u53F8",
3183
3197
  style: {
3184
3198
  width: '200px'
@@ -3193,7 +3207,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3193
3207
  return option.label.includes(input);
3194
3208
  }
3195
3209
  }), /*#__PURE__*/React.createElement(Input, {
3196
- disabled: disabled,
3210
+ disabled: disabled || !canEdit,
3197
3211
  placeholder: "\u7269\u6D41\u5355\u53F7",
3198
3212
  onChange: function onChange(e) {
3199
3213
  return changeHandle(e.target.value, 'interceptCode');
@@ -3204,7 +3218,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3204
3218
  required: required,
3205
3219
  key: 'interceptType'
3206
3220
  }, /*#__PURE__*/React.createElement(Select, {
3207
- disabled: disabled,
3221
+ disabled: disabled || !canEdit,
3208
3222
  style: {
3209
3223
  width: '200px'
3210
3224
  },
@@ -3220,24 +3234,26 @@ var LogisticsInterception = function LogisticsInterception(props) {
3220
3234
  }
3221
3235
  })), /*#__PURE__*/React.createElement(Item, {
3222
3236
  label: '新派送地',
3223
- required: required,
3237
+ required: true,
3224
3238
  key: 'newAddress',
3225
- hidden: isInterface && showNewAddress
3239
+ hidden: !showNewAddress
3226
3240
  }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Province, {
3227
3241
  value: value === null || value === void 0 ? void 0 : value.interceptAddress,
3228
3242
  onChange: function onChange(val) {
3229
3243
  return changeHandle(val, 'interceptAddress');
3230
3244
  },
3231
3245
  options: [],
3232
- disabled: disabled
3246
+ disabled: disabled || !canEdit
3233
3247
  }), /*#__PURE__*/React.createElement(Input, {
3234
- disabled: disabled,
3248
+ value: value === null || value === void 0 ? void 0 : value.interceptDetail,
3249
+ disabled: disabled || !canEdit,
3235
3250
  placeholder: "\u8BE6\u7EC6\u5730\u5740",
3236
3251
  onChange: function onChange(e) {
3237
3252
  return changeHandle(e.target.value, 'interceptDetail');
3238
3253
  }
3239
3254
  })), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Input, {
3240
- disabled: disabled,
3255
+ value: value === null || value === void 0 ? void 0 : value.interceptReceiverName,
3256
+ disabled: disabled || !canEdit,
3241
3257
  style: {
3242
3258
  width: '200px'
3243
3259
  },
@@ -3246,7 +3262,8 @@ var LogisticsInterception = function LogisticsInterception(props) {
3246
3262
  return changeHandle(e.target.value, 'interceptReceiverName');
3247
3263
  }
3248
3264
  }), /*#__PURE__*/React.createElement(Input, {
3249
- disabled: disabled,
3265
+ value: value === null || value === void 0 ? void 0 : value.interceptReceiverMobile,
3266
+ disabled: disabled || !canEdit,
3250
3267
  placeholder: "\u6536\u4EF6\u4EBA\u7535\u8BDD",
3251
3268
  onChange: function onChange(e) {
3252
3269
  return changeHandle(e.target.value, 'interceptReceiverMobile');
@@ -3270,6 +3287,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3270
3287
  return option.label.includes(input);
3271
3288
  }
3272
3289
  }), (value === null || value === void 0 ? void 0 : value.interceptStatus) === 'OTHER' && /*#__PURE__*/React.createElement(Input, {
3290
+ disabled: disabled || canEdit,
3273
3291
  style: {
3274
3292
  width: '200px'
3275
3293
  },
package/dist/index.js CHANGED
@@ -3132,9 +3132,13 @@ var LogisticsInterception = function LogisticsInterception(props) {
3132
3132
  value = _props$value === void 0 ? {} : _props$value,
3133
3133
  _props$logisticsOptio = props.logisticsOptions,
3134
3134
  logisticsOptions = _props$logisticsOptio === void 0 ? [] : _props$logisticsOptio,
3135
- required = props.required,
3135
+ _props$required = props.required,
3136
+ required = _props$required === void 0 ? false : _props$required,
3136
3137
  onChange = props.onChange,
3137
- disabled = props.disabled;
3138
+ _props$disabled = props.disabled,
3139
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
3140
+ _props$isEditing = props.isEditing,
3141
+ isEditing = _props$isEditing === void 0 ? false : _props$isEditing;
3138
3142
  var _useState = React.useState([]),
3139
3143
  _useState2 = _slicedToArray(_useState, 2),
3140
3144
  typeOptions = _useState2[0],
@@ -3143,40 +3147,54 @@ var LogisticsInterception = function LogisticsInterception(props) {
3143
3147
  _useState4 = _slicedToArray(_useState3, 2),
3144
3148
  statusOptions = _useState4[0],
3145
3149
  setStatusOptions = _useState4[1];
3146
- var _useState5 = React.useState(true),
3150
+ var _useState5 = React.useState(false),
3147
3151
  _useState6 = _slicedToArray(_useState5, 2),
3148
3152
  isInterface = _useState6[0],
3149
3153
  setIsInterface = _useState6[1];
3154
+ var canEdit = React.useMemo(function () {
3155
+ //非对接公司可以修改
3156
+ if (!isInterface) return true;
3157
+ //已对接公司在拦截中可以修改
3158
+ var INTERCEPTING = statusOptions.some(function (item) {
3159
+ return item.value === (value === null || value === void 0 ? void 0 : value.interceptStatus) && (item === null || item === void 0 ? void 0 : item.showInterceptionBtn);
3160
+ });
3161
+ return isEditing && (value === null || value === void 0 ? void 0 : value.interceptStatus) ? INTERCEPTING && isEditing : true;
3162
+ }, [value, statusOptions, isInterface, isEditing]);
3150
3163
  React.useEffect(function () {
3151
- onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread2(_objectSpread2({}, value), {}, {
3152
- interceptType: undefined,
3153
- interceptAddress: [],
3154
- interceptDetail: '',
3155
- interceptReceiverName: '',
3156
- interceptReceiverMobile: '',
3157
- interceptStatus: '',
3158
- interceptOther: ''
3159
- }));
3160
3164
  if (!(value === null || value === void 0 ? void 0 : value.interceptCompany)) {
3161
3165
  setTypeOptions([]);
3162
3166
  setStatusOptions([]);
3163
- setIsInterface(true);
3167
+ setIsInterface(false);
3164
3168
  return;
3165
3169
  }
3166
3170
  var interceptCompany = logisticsOptions.find(function (item) {
3167
3171
  return item.expressCode === (value === null || value === void 0 ? void 0 : value.interceptCompany);
3168
3172
  });
3169
3173
  setTypeOptions((interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.interceptionTypeList) || []);
3174
+ setStatusOptions((interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.interceptionStatusList) || []);
3170
3175
  setIsInterface(interceptCompany === null || interceptCompany === void 0 ? void 0 : interceptCompany.isInterface);
3171
3176
  }, [value === null || value === void 0 ? void 0 : value.interceptCompany]);
3177
+ //是否展示新地址
3172
3178
  var showNewAddress = React.useMemo(function () {
3173
3179
  var _find, _find$config;
3174
3180
  return (_find = (typeOptions || []).find(function (item) {
3175
3181
  return item.value === (value === null || value === void 0 ? void 0 : value.interceptType);
3176
3182
  })) === null || _find === void 0 ? void 0 : (_find$config = _find.config) === null || _find$config === void 0 ? void 0 : _find$config.showAddress;
3177
- }, [value === null || value === void 0 ? void 0 : value.interceptType]);
3183
+ }, [value === null || value === void 0 ? void 0 : value.interceptType, typeOptions, value === null || value === void 0 ? void 0 : value.interceptCompany]);
3178
3184
  var changeHandle = function changeHandle(val, type) {
3179
3185
  var newValue = _objectSpread2(_objectSpread2({}, value), {}, _defineProperty({}, type, val));
3186
+ if (type === 'interceptCompany') {
3187
+ newValue = _objectSpread2(_objectSpread2({}, value), {}, {
3188
+ interceptCompany: val,
3189
+ interceptType: 'RETURN',
3190
+ interceptAddress: [],
3191
+ interceptDetail: '',
3192
+ interceptReceiverName: '',
3193
+ interceptReceiverMobile: '',
3194
+ interceptStatus: '',
3195
+ interceptOther: ''
3196
+ });
3197
+ }
3180
3198
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
3181
3199
  };
3182
3200
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Item, {
@@ -3184,11 +3202,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3184
3202
  required: required,
3185
3203
  key: 'logistics'
3186
3204
  }, /*#__PURE__*/React__default['default'].createElement(antd.Space, null, /*#__PURE__*/React__default['default'].createElement(antd.Select, {
3187
- disabled: disabled,
3188
- fieldNames: {
3189
- label: 'expressName',
3190
- value: 'expressCode'
3191
- },
3205
+ disabled: disabled || !canEdit,
3192
3206
  placeholder: "\u7269\u6D41\u516C\u53F8",
3193
3207
  style: {
3194
3208
  width: '200px'
@@ -3203,7 +3217,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3203
3217
  return option.label.includes(input);
3204
3218
  }
3205
3219
  }), /*#__PURE__*/React__default['default'].createElement(antd.Input, {
3206
- disabled: disabled,
3220
+ disabled: disabled || !canEdit,
3207
3221
  placeholder: "\u7269\u6D41\u5355\u53F7",
3208
3222
  onChange: function onChange(e) {
3209
3223
  return changeHandle(e.target.value, 'interceptCode');
@@ -3214,7 +3228,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3214
3228
  required: required,
3215
3229
  key: 'interceptType'
3216
3230
  }, /*#__PURE__*/React__default['default'].createElement(antd.Select, {
3217
- disabled: disabled,
3231
+ disabled: disabled || !canEdit,
3218
3232
  style: {
3219
3233
  width: '200px'
3220
3234
  },
@@ -3230,24 +3244,26 @@ var LogisticsInterception = function LogisticsInterception(props) {
3230
3244
  }
3231
3245
  })), /*#__PURE__*/React__default['default'].createElement(Item, {
3232
3246
  label: '新派送地',
3233
- required: required,
3247
+ required: true,
3234
3248
  key: 'newAddress',
3235
- hidden: isInterface && showNewAddress
3249
+ hidden: !showNewAddress
3236
3250
  }, /*#__PURE__*/React__default['default'].createElement(antd.Space, null, /*#__PURE__*/React__default['default'].createElement(Province, {
3237
3251
  value: value === null || value === void 0 ? void 0 : value.interceptAddress,
3238
3252
  onChange: function onChange(val) {
3239
3253
  return changeHandle(val, 'interceptAddress');
3240
3254
  },
3241
3255
  options: [],
3242
- disabled: disabled
3256
+ disabled: disabled || !canEdit
3243
3257
  }), /*#__PURE__*/React__default['default'].createElement(antd.Input, {
3244
- disabled: disabled,
3258
+ value: value === null || value === void 0 ? void 0 : value.interceptDetail,
3259
+ disabled: disabled || !canEdit,
3245
3260
  placeholder: "\u8BE6\u7EC6\u5730\u5740",
3246
3261
  onChange: function onChange(e) {
3247
3262
  return changeHandle(e.target.value, 'interceptDetail');
3248
3263
  }
3249
3264
  })), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement(antd.Space, null, /*#__PURE__*/React__default['default'].createElement(antd.Input, {
3250
- disabled: disabled,
3265
+ value: value === null || value === void 0 ? void 0 : value.interceptReceiverName,
3266
+ disabled: disabled || !canEdit,
3251
3267
  style: {
3252
3268
  width: '200px'
3253
3269
  },
@@ -3256,7 +3272,8 @@ var LogisticsInterception = function LogisticsInterception(props) {
3256
3272
  return changeHandle(e.target.value, 'interceptReceiverName');
3257
3273
  }
3258
3274
  }), /*#__PURE__*/React__default['default'].createElement(antd.Input, {
3259
- disabled: disabled,
3275
+ value: value === null || value === void 0 ? void 0 : value.interceptReceiverMobile,
3276
+ disabled: disabled || !canEdit,
3260
3277
  placeholder: "\u6536\u4EF6\u4EBA\u7535\u8BDD",
3261
3278
  onChange: function onChange(e) {
3262
3279
  return changeHandle(e.target.value, 'interceptReceiverMobile');
@@ -3280,6 +3297,7 @@ var LogisticsInterception = function LogisticsInterception(props) {
3280
3297
  return option.label.includes(input);
3281
3298
  }
3282
3299
  }), (value === null || value === void 0 ? void 0 : value.interceptStatus) === 'OTHER' && /*#__PURE__*/React__default['default'].createElement(antd.Input, {
3300
+ disabled: disabled || canEdit,
3283
3301
  style: {
3284
3302
  width: '200px'
3285
3303
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/basic-components",
3
- "version": "0.2.2-alpha.0",
3
+ "version": "0.2.2-alpha.2",
4
4
  "description": "> TODO: description",
5
5
  "author": "wangzhenggui <jianjia.wzg@raycloud.com>",
6
6
  "homepage": "",
@@ -13,7 +13,7 @@
13
13
  "async": "yarn build && yalc push",
14
14
  "watch": "nodemon --ignore dist/ --ignore node_modules/ --watch src/ -C -e ts,tsx,less --debug -x 'yarn async'"
15
15
  },
16
- "gitHead": "d44b310feb505019c7ffb93c23826b045e71e627",
16
+ "gitHead": "9b5e231fe191b63e8cba25fffa6e7da93a99eba6",
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },