import 'antd/es/popconfirm/style';
import _Popconfirm from 'antd/es/popconfirm';
import 'antd/es/divider/style';
import _Divider from 'antd/es/divider';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import _get from 'lodash/get';
import { _ as __extends, d as __assign, a as __spreadArray, b as __awaiter, c as __generator } from './index.js';
import React__default, { Component } from 'react';
import { BaseTableOld, BaseQuery, DataSelect, formatTimeToStandardApi, GeneralComponents_DictionarySelect, GeneralComponents_InputWithLabel, TimePicker_L, DatePicker_L, PatientAutoComplete, createResources, getResources, updateResources, GeneralComponents_DictionarySelect_Display, formatTimeToStandard, BaseListOld } from '@lm_fe/components_m';
import 'antd/es/modal/style';
import _Modal from 'antd/es/modal';
import 'antd/es/tooltip/style';
import _Tooltip from 'antd/es/tooltip';
import 'antd/es/switch/style';
import _Switch from 'antd/es/switch';
import 'antd/es/form/style';
import _Form from 'antd/es/form';
import 'antd/es/input/style';
import _Input from 'antd/es/input';
import 'antd/es/message/style';
import _message from 'antd/es/message';
import { mchcStore, APP_CONFIG } from '@lm_fe/env';
import _map from 'lodash/map';
import _pick from 'lodash/pick';
import { safe_json_parse } from '@lm_fe/utils';
import dayjs from 'dayjs';
import 'antd/es/row/style';
import _Row from 'antd/es/row';
import 'antd/es/col/style';
import _Col from 'antd/es/col';
import _set from 'lodash/set';
import _isEqual from 'lodash/isEqual';
import _isEmpty from 'lodash/isEmpty';
import _filter from 'lodash/filter';
import { PlusCircleOutlined, MinusCircleOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { LazyAntd } from '@lm_fe/components';
import 'antd/es/badge/style';
import _Badge from 'antd/es/badge';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/size';
import 'lodash/orderBy';
import 'antd/es/collapse/style';
import 'antd/es/collapse';
import 'lodash/assign';
import '@lm_fe/service';
import '@lm_fe/pages';
var ProductsTable = function (_super) {
  __extends(ProductsTable, _super);
  function ProductsTable() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  return ProductsTable;
}(BaseTableOld);
var queryFormDescriptions = {
  contentType: {
    label: '任务类型',
    inputType: 'select',
    filterType: 'equals',
    url: '/api/dictionaries/134'
  },
  releaseStatus: {
    label: '启用状态',
    inputType: 'select',
    filterType: 'equals',
    options: [{
      value: 1,
      label: '开启'
    }, {
      value: 2,
      label: '关闭'
    }]
  },
  runStatus: {
    label: '运行情况',
    inputType: 'select',
    filterType: 'equals',
    url: '/api/dictionaries/211'
  }
};
var Query = function (_super) {
  __extends(Query, _super);
  function Query() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.state = {
      queryFormDescriptions: queryFormDescriptions
    };
    return _this;
  }
  return Query;
}(BaseQuery);
var fromApi = function fromApi(data) {
  var _a;
  var contentType = _get(data, 'contentType');
  var educationContent, educationType;
  if (contentType === 1) {
    educationContent = _get(data, 'knowledge.id');
    educationType = _get(data, 'knowledge.type');
  }
  if (contentType === 2) {
    educationContent = _get(data, 'video.id');
  }
  if (contentType === 3) {
    educationContent = _get(data, 'url');
  }
  if (contentType === 4) {
    educationContent = (_a = data === null || data === void 0 ? void 0 : data.questionnaireId) !== null && _a !== void 0 ? _a : _get(data, 'workQuestion.id');
  }
  var pregnantLimitsNote = safe_json_parse(_get(data, 'pregnantLimitsNote'));
  var pushTime = safe_json_parse(_get(data, 'pushTime'));
  return __assign(__assign({}, _pick(data, ['title'])), {
    releaseStatus: _get(data, 'releaseStatus') === 1 ? true : false,
    diagnosisKeywords: _get(pregnantLimitsNote, 'diagnosisKeywords'),
    operationKeywords: _get(pregnantLimitsNote, 'operationKeywords'),
    contentType: {
      selectedData: contentType,
      otherNote: ''
    },
    pushObject: {
      selectedData: _get(data, 'pregnantLimits'),
      otherNote: ''
    },
    educationContent: educationContent,
    educationType: educationType,
    gestationalRange: {
      appointRange: _get(pregnantLimitsNote, 'gesweekLimits'),
      min: _get(pregnantLimitsNote, 'gesweekGt'),
      max: _get(pregnantLimitsNote, 'gesweekLt'),
      value: _get(pregnantLimitsNote, 'gesweek')
    },
    ageRange: {
      appointRange: _get(pregnantLimitsNote, 'ageLimits'),
      min: _get(pregnantLimitsNote, 'ageGt'),
      max: _get(pregnantLimitsNote, 'ageLt'),
      value: _get(pregnantLimitsNote, 'age')
    },
    dangeLevel: {
      selectedData: _get(pregnantLimitsNote, 'highriskGrade'),
      otherNote: ''
    },
    inspectionReport: {
      selectedData: _get(pregnantLimitsNote, 'inspectionType'),
      otherNote: ''
    },
    inspectionReportResult: {
      selectedData: _get(pregnantLimitsNote, 'inspectionResult'),
      otherNote: ''
    },
    diseases: {
      selectedData: _get(pregnantLimitsNote, 'diseases'),
      otherNote: ''
    },
    userLabel: {
      selectedData: _get(pregnantLimitsNote, 'tag'),
      otherNote: ''
    },
    pushFrequency: {
      selectedData: _get(data, 'pushFrequency'),
      otherNote: ''
    },
    pushFrequencyNote: {
      time: _get(pushTime, 'time') ? dayjs(_get(pushTime, 'time'), 'HH:mm:ss') : undefined,
      date: _get(pushTime, 'date') ? dayjs(_get(pushTime, 'date'), 'HH:mm:ss') : undefined,
      gestationalWeek: _get(pushTime, 'gesweek'),
      pushDateType: _get(pushTime, 'timeType'),
      pushTimeType: _get(pushTime, 'timeNode'),
      day: _get(pushTime, 'day')
    },
    outpatientNO: _map(_get(pregnantLimitsNote, 'outpatientNOs'), function (outpatientNO) {
      return {
        key: Math.random(),
        value: outpatientNO
      };
    })
  });
};
var toApi = function toApi(data) {
  var _a;
  var educationContentObj = {};
  var contentType = _get(data, 'contentType.selectedData');
  if (contentType === 1) {
    educationContentObj = {
      knowledge: {
        id: _get(data, 'educationContent')
      }
    };
  }
  if (contentType === 2) {
    educationContentObj = {
      video: {
        id: _get(data, 'educationContent')
      }
    };
  }
  if (contentType === 3) {
    educationContentObj = {
      url: _get(data, 'educationContent')
    };
  }
  if (contentType === 4) {
    var id = _get(data, 'educationContent');
    var q_obj = (_a = DataSelect.get_data('work-questions', id)) !== null && _a !== void 0 ? _a : {};
    educationContentObj = {
      questionnaireId: q_obj['id'],
      questionnaireTitle: q_obj['title'],
      workQuestion: __assign({}, q_obj)
    };
  }
  var transferData = __assign(__assign(__assign({}, _pick(data, ['id', 'title'])), educationContentObj), {
    releaseStatus: _get(data, 'releaseStatus') ? 1 : 2,
    pregnantLimits: _get(data, 'pushObject.selectedData'),
    contentType: contentType,
    pregnantLimitsNote: JSON.stringify({
      gesweekLimits: _get(data, 'gestationalRange.appointRange'),
      gesweekGt: _get(data, 'gestationalRange.min'),
      gesweekLt: _get(data, 'gestationalRange.max'),
      gesweek: _get(data, 'gestationalRange.value'),
      operationGesweekLimits: _get(data, 'gestationalRange.appointRange'),
      operationGesweekGt: _get(data, 'gestationalRange.min'),
      operationGesweekLt: _get(data, 'gestationalRange.max'),
      operationGesweek: _get(data, 'gestationalRange.value'),
      ageLimits: _get(data, 'ageRange.appointRange'),
      ageGt: _get(data, 'ageRange.min'),
      diagnosisKeywords: _get(data, 'diagnosisKeywords'),
      operationKeywords: _get(data, 'operationKeywords'),
      ageLt: _get(data, 'ageRange.max'),
      age: _get(data, 'ageRange.value'),
      highriskGrade: _get(data, 'dangeLevel.selectedData'),
      inspectionType: _get(data, 'inspectionReport.selectedData'),
      inspectionResult: _get(data, 'inspectionReportResult.selectedData'),
      outpatientNOs: _map(_get(data, 'outpatientNO'), function (item) {
        return _get(item, 'value');
      }),
      diseases: _get(data, 'diseases.selectedData'),
      tag: _get(data, 'userLabel.selectedData')
    }),
    pushFrequency: _get(data, 'pushFrequency.selectedData'),
    pushTime: JSON.stringify({
      time: formatTimeToStandardApi(_get(data, 'pushFrequencyNote.time'), 'HH:mm:ss'),
      date: formatTimeToStandardApi(_get(data, 'pushFrequencyNote.date')),
      gesweek: _get(data, 'pushFrequencyNote.gestationalWeek'),
      timeType: _get(data, 'pushFrequencyNote.pushDateType'),
      timeNode: _get(data, 'pushFrequencyNote.pushTimeType'),
      day: _get(data, 'pushFrequencyNote.day')
    })
  });
  return transferData;
};
var PushDate = function (_super) {
  __extends(PushDate, _super);
  function PushDate() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.state = {
      data: {
        pushDateType: undefined,
        pushTimeType: undefined,
        gestationalWeek: undefined,
        day: undefined,
        time: undefined,
        date: undefined
      }
    };
    _this.handleChange = function (name) {
      return function (e) {
        var data = _this.state.data;
        var onChange = _this.props.onChange;
        var tempData = __assign({}, data);
        if (['time', 'date', 'gestationalWeek', 'day'].indexOf(name) > -1) {
          _set(tempData, name, e);
        }
        if (['pushDateType', 'pushTimeType'].indexOf(name) > -1) {
          _set(tempData, name, _get(e, 'selectedData'));
        }
        _this.setState({
          data: tempData
        });
        onChange && onChange(tempData);
      };
    };
    _this.renderOthers = function () {
      var data = _this.state.data;
      var pushTimeType = /*#__PURE__*/React__default.createElement(_Col, {
        span: 6
      }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
        type: "select",
        mode: "single",
        uniqueKey: "Task.pushTimeType",
        onChange: _this.handleChange('pushTimeType'),
        value: {
          selectedData: _get(data, 'pushTimeType'),
          otherNote: ''
        }
      }));
      var pushGestationalWeek = /*#__PURE__*/React__default.createElement(_Col, {
        span: 4
      }, /*#__PURE__*/React__default.createElement(GeneralComponents_InputWithLabel, {
        onChange: _this.handleChange('gestationalWeek'),
        labelAfter: "\u5468",
        value: _get(data, 'gestationalWeek')
      }));
      var pushDay = /*#__PURE__*/React__default.createElement(_Col, {
        span: 4
      }, /*#__PURE__*/React__default.createElement(GeneralComponents_InputWithLabel, {
        onChange: _this.handleChange('day'),
        labelAfter: "\u5929",
        value: _get(data, 'day')
      }));
      var pushTimePicker = /*#__PURE__*/React__default.createElement(_Col, {
        span: 4
      }, /*#__PURE__*/React__default.createElement(TimePicker_L, {
        format: "HH:mm:ss",
        onChange: _this.handleChange('time'),
        value: _get(data, 'time')
      }));
      var pushDatePicker = /*#__PURE__*/React__default.createElement(_Col, {
        span: 4
      }, /*#__PURE__*/React__default.createElement(DatePicker_L, {
        onChange: _this.handleChange('date'),
        value: _get(data, 'date')
      }));
      if (_get(data, 'pushDateType') === 11) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, pushTimeType, pushGestationalWeek, pushDay, pushTimePicker);
      }
      if (_get(data, 'pushDateType') === 12) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, pushDatePicker, pushTimePicker);
      }
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, pushTimeType, pushDay, pushTimePicker);
    };
    return _this;
  }
  PushDate.prototype.componentDidMount = function () {
    var value = this.props.value;
    this.setState({
      data: value
    });
  };
  PushDate.getDerivedStateFromProps = function (nextProps, prevState) {
    if (!_isEqual(_get(nextProps, 'value'), _get(prevState, 'data'))) {
      return {
        data: _get(nextProps, 'value')
      };
    }
    return null;
  };
  PushDate.prototype.render = function () {
    var data = this.state.data;
    return /*#__PURE__*/React__default.createElement(_Row, {
      style: {
        alignItems: 'center'
      }
    }, /*#__PURE__*/React__default.createElement(_Col, {
      span: 6
    }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
      type: "select",
      mode: "single",
      uniqueKey: "Task.pushDateType",
      onChange: this.handleChange('pushDateType'),
      value: {
        selectedData: _get(data, 'pushDateType'),
        otherNote: ''
      }
    })), this.renderOthers());
  };
  return PushDate;
}(Component);
var RangeInput = function (_super) {
  __extends(RangeInput, _super);
  function RangeInput() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.state = {
      data: {}
    };
    _this.handleChange = function (type) {
      return function (e) {
        var onChange = _this.props.onChange;
        var data = _this.state.data;
        var tempData = __assign({}, data);
        if (type === 'appointRange') {
          _set(tempData, type, _get(e, 'selectedData'));
          _this.setState(__assign(__assign({}, data), {
            appointRange: _get(e, 'selectedData')
          }));
        }
        if (type === 'min' || type === 'max' || type === 'value') {
          _set(tempData, type, _get(e, 'target.value'));
        }
        _this.setState({
          data: tempData
        });
        onChange && onChange(tempData);
      };
    };
    _this.renderRange = function () {
      var data = _this.state.data;
      if (_get(data, 'appointRange') === 6) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
      }
      if (_get(data, 'appointRange') === 1) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Col, {
          span: 7
        }, /*#__PURE__*/React__default.createElement(_Input, {
          onChange: _this.handleChange('min'),
          value: _get(data, 'min')
        })), /*#__PURE__*/React__default.createElement(_Col, {
          style: {
            textAlign: 'center'
          },
          span: 1
        }, /*#__PURE__*/React__default.createElement("span", null, "~")), /*#__PURE__*/React__default.createElement(_Col, {
          span: 7
        }, /*#__PURE__*/React__default.createElement(_Input, {
          onChange: _this.handleChange('max'),
          value: _get(data, 'max')
        })));
      }
      return /*#__PURE__*/React__default.createElement(_Col, {
        span: 7
      }, /*#__PURE__*/React__default.createElement(_Input, {
        onChange: _this.handleChange('value'),
        value: _get(data, 'value')
      }));
    };
    return _this;
  }
  RangeInput.prototype.componentDidMount = function () {
    var value = this.props.value;
    this.setState({
      data: value
    });
  };
  RangeInput.prototype.render = function () {
    var data = this.state.data;
    var labelAfter = this.props.labelAfter;
    return /*#__PURE__*/React__default.createElement(_Row, {
      style: {
        alignItems: 'center'
      }
    }, /*#__PURE__*/React__default.createElement(_Col, {
      span: 8
    }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
      type: "select",
      mode: "single",
      uniqueKey: "Task.appointRange",
      onChange: this.handleChange('appointRange'),
      value: {
        selectedData: _get(data, 'appointRange'),
        otherNote: ''
      }
    })), this.renderRange(), _get(data, 'appointRange') !== 6 && /*#__PURE__*/React__default.createElement(_Col, {
      span: 1
    }, /*#__PURE__*/React__default.createElement("span", null, labelAfter)));
  };
  return RangeInput;
}(Component);
var UserSelect = function (_super) {
  __extends(UserSelect, _super);
  function UserSelect() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.state = {
      users: [{
        key: Math.random()
      }]
    };
    _this.handleAdd = function () {
      var users = _this.state.users;
      var onChange = _this.props.onChange;
      var newUsers = __spreadArray(__spreadArray([], users, true), [{
        key: Math.random()
      }], false);
      _this.setState({
        users: newUsers
      });
      onChange && onChange(newUsers);
    };
    _this.handleDelete = function (key) {
      return function () {
        var users = _this.state.users;
        var onChange = _this.props.onChange;
        var newUsers = _filter(users, function (user) {
          return _get(user, 'key') !== key;
        });
        _this.setState({
          users: newUsers
        });
        onChange && onChange(newUsers);
      };
    };
    _this.handleChange = function (key) {
      return function (value) {
        var onChange = _this.props.onChange;
        var users = _this.state.users;
        var newUsers = _map(users, function (user) {
          if (_get(user, 'key') === key) {
            return __assign(__assign({}, user), {
              value: value
            });
          }
          return user;
        });
        _this.setState({
          users: newUsers
        });
        onChange && onChange(newUsers);
      };
    };
    return _this;
  }
  UserSelect.prototype.componentDidMount = function () {
    var value = this.props.value;
    if (!_isEmpty(value)) {
      this.setState({
        users: value
      });
    }
  };
  UserSelect.prototype.render = function () {
    var _this = this;
    var users = this.state.users;
    return /*#__PURE__*/React__default.createElement("div", null, _map(users, function (user, index) {
      return /*#__PURE__*/React__default.createElement(_Row, {
        style: {
          alignItems: 'center'
        },
        key: _get(user, 'key')
      }, /*#__PURE__*/React__default.createElement(_Col, {
        span: 20
      }, /*#__PURE__*/React__default.createElement(PatientAutoComplete, {
        value: _get(user, 'value'),
        onChange: _this.handleChange(_get(user, 'key'))
      })), /*#__PURE__*/React__default.createElement(_Col, {
        span: 1,
        offset: 1
      }, /*#__PURE__*/React__default.createElement(PlusCircleOutlined, {
        onClick: _this.handleAdd
      })), /*#__PURE__*/React__default.createElement(_Col, {
        span: 1,
        offset: 1
      }, index !== 0 && /*#__PURE__*/React__default.createElement(MinusCircleOutlined, {
        style: {
          color: 'red'
        },
        onClick: _this.handleDelete(_get(user, 'key'))
      })));
    }));
  };
  return UserSelect;
}(Component);
LazyAntd.Tree;
LazyAntd.TreeSelect;
var Select = LazyAntd.Select;
LazyAntd.Table;
LazyAntd.Dropdown;
LazyAntd.Pagination;
var ModalForm = function (_super) {
  __extends(ModalForm, _super);
  function ModalForm() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.state = {
      educationType: '',
      contentType: ''
    };
    _this.handleSubmit = function () {
      return __awaiter(_this, void 0, void 0, function () {
        var _a, id, onCancel, onSearch, formData, data;
        return __generator(this, function (_b) {
          switch (_b.label) {
            case 0:
              _a = this.props, id = _a.id, onCancel = _a.onCancel, onSearch = _a.onSearch;
              return [4, this.form.validateFields()];
            case 1:
              _b.sent();
              formData = this.form.getFieldsValue();
              data = toApi(__assign(__assign({}, formData), {
                id: id
              }));
              if (!id) return [3, 3];
              return [4, updateResources('/api/knowledge-tasks', data)];
            case 2:
              _b.sent();
              return [3, 5];
            case 3:
              return [4, createResources('/api/knowledge-tasks', data)];
            case 4:
              _b.sent();
              _b.label = 5;
            case 5:
              _message.success('操作成功');
              onCancel && onCancel();
              onSearch && onSearch();
              return [2];
          }
        });
      });
    };
    _this.handleFieldsChange = function (changedFields, allFields) {
      _this.forceUpdate();
    };
    _this.renderKnowlodgeFormItems = function () {
      var contentType, showEducationType, educationType;
      var educationContentItem = /*#__PURE__*/React__default.createElement(_Form.Item, {
        name: "educationContent",
        label: "\u5BA3\u6559\u5185\u5BB9"
      }, /*#__PURE__*/React__default.createElement(_Input, {
        disabled: true
      }));
      if (_this.form) {
        contentType = _this.form.getFieldValue('contentType');
        educationType = _this.form.getFieldValue('educationType');
        if (_get(contentType, 'selectedData') === 1) {
          showEducationType = true;
          var educationContentUrl = _get(educationType, 'selectedData') ? "knowledges?page=0&size=99999&type.equals=".concat(_get(educationType, 'selectedData'), "&sort=id,desc") : 'knowledges?page=0&size=99999&sort=id,desc';
          educationContentItem = /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "educationContent",
            label: "\u5BA3\u6559\u5185\u5BB91"
          }, /*#__PURE__*/React__default.createElement(DataSelect, {
            key: educationContentUrl,
            url: educationContentUrl,
            valueKey: "id",
            labelKey: "title"
          }));
        }
        if (_get(contentType, 'selectedData') === 2) {
          showEducationType = false;
          educationContentItem = /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "educationContent",
            label: "\u5BA3\u6559\u5185\u5BB92"
          }, /*#__PURE__*/React__default.createElement(DataSelect, {
            key: "videos?page=0&size=99999&sort=id,desc",
            url: "videos?page=0&size=99999&sort=id,desc",
            valueKey: "id",
            labelKey: "title"
          }));
        }
        if (_get(contentType, 'selectedData') === 3) {
          showEducationType = false;
          educationContentItem = /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "educationContent",
            label: "\u5BA3\u6559\u5185\u5BB93"
          }, /*#__PURE__*/React__default.createElement(_Input, null));
        }
        if (_get(contentType, 'selectedData') === 4) {
          showEducationType = false;
          educationContentItem = /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "educationContent",
            label: "\u5BA3\u6559\u5185\u5BB94"
          }, /*#__PURE__*/React__default.createElement(DataSelect, {
            key: "work-questions?page=0&size=99999&sort=id,desc",
            url: "work-questions?page=0&size=99999&sort=id,desc",
            valueKey: "id",
            labelKey: "title"
          }));
        }
      }
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, showEducationType && /*#__PURE__*/React__default.createElement(_Form.Item, {
        name: "educationType",
        label: "\u5BA3\u6559\u7C7B\u578B"
      }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
        placeholder: "\u8BF7\u9009\u62E9\u5BA3\u6559\u7C7B\u578B",
        uniqueKey: "Knowledge.knowledgeType"
      })), educationContentItem);
    };
    _this.renderUserFormItems = function () {
      var pushObject;
      var pushObjectItems = /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
      if (_this.form) {
        pushObject = _this.form.getFieldValue('pushObject');
        if (_get(pushObject, 'selectedData') === 3) {
          pushObjectItems = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "gestationalRange",
            label: "\u5B55\u5468\u8303\u56F4"
          }, /*#__PURE__*/React__default.createElement(RangeInput, {
            labelAfter: "\u5468"
          })), /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "ageRange",
            label: "\u5E74\u9F84\u8303\u56F4"
          }, /*#__PURE__*/React__default.createElement(RangeInput, {
            labelAfter: "\u5C81"
          })), /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "dangeLevel",
            label: "\u9AD8\u5371\u7B49\u7EA7"
          }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
            type: "select",
            mode: "single",
            uniqueKey: "Task.dangeLevel"
          })), /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "diseases",
            label: "\u4F20\u67D3\u75C5"
          }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
            type: "select",
            mode: "multiple",
            uniqueKey: "Task.diseases"
          })), /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "userLabel",
            label: "\u7528\u6237\u6807\u7B7E"
          }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
            type: "select",
            mode: "single",
            uniqueKey: "Task.tag"
          })));
        }
        if (_get(pushObject, 'selectedData') === 4) {
          pushObjectItems = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "outpatientNO",
            label: "\u5C31\u8BCA\u5361\u53F7"
          }, /*#__PURE__*/React__default.createElement(UserSelect, null)));
        }
        if (_get(pushObject, 'selectedData') === 5) {
          pushObjectItems = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "operationKeywords",
            label: "\u624B\u672F\u540D\u79F0\u5173\u952E\u8BCD"
          }, /*#__PURE__*/React__default.createElement(Select, {
            mode: "tags",
            defaultOpen: false
          })), /*#__PURE__*/React__default.createElement(_Form.Item, {
            name: "gestationalRange",
            label: "\u5B55\u5468\u8303\u56F4"
          }, /*#__PURE__*/React__default.createElement(RangeInput, {
            labelAfter: "\u5468"
          })));
        }
      }
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, pushObjectItems);
    };
    _this.judgeReportBtnPermission = function () {
      var _a, _b, _c;
      var permissions = Object.values((_c = (_b = (_a = mchcStore.state) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.permissionsMapping) !== null && _c !== void 0 ? _c : {});
      for (var index = 0; index < permissions.length; index++) {
        var permission = permissions[index];
        if (_get(permission, 'type') === 'function' && _get(permission, 'key') === 'follow-up-report-permission') {
          return true;
        }
      }
      return false;
    };
    return _this;
  }
  ModalForm.prototype.componentDidMount = function () {
    return __awaiter(this, void 0, void 0, function () {
      var id, form, result, data;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            id = this.props.id;
            form = this.form;
            if (!id) return [3, 2];
            return [4, getResources("/api/knowledge-tasks/".concat(id))];
          case 1:
            result = _a.sent();
            data = fromApi(result);
            form.setFieldsValue(data);
            this.forceUpdate();
            _a.label = 2;
          case 2:
            return [2];
        }
      });
    });
  };
  ModalForm.prototype.render = function () {
    var _this = this;
    var _a = this.props,
      visible = _a.visible,
      onCancel = _a.onCancel;
    var reportBtnPermission = this.judgeReportBtnPermission();
    return /*#__PURE__*/React__default.createElement(_Form, {
      ref: function ref(form) {
        _this.form = form;
      },
      labelCol: {
        span: 4
      },
      wrapperCol: {
        span: 20
      },
      onFieldsChange: this.handleFieldsChange
    }, /*#__PURE__*/React__default.createElement(_Modal, {
      title: "\u7F16\u8F91\u4EFB\u52A1",
      width: 800,
      onOk: this.handleSubmit,
      visible: visible,
      onCancel: onCancel
    }, /*#__PURE__*/React__default.createElement(_Form.Item, {
      rules: [{
        required: true,
        message: '任务标题是必填项'
      }],
      name: "title",
      label: "\u4EFB\u52A1\u6807\u9898"
    }, /*#__PURE__*/React__default.createElement(_Input, null)), /*#__PURE__*/React__default.createElement(_Form.Item, {
      rules: [{
        required: true,
        message: '任务类型是必填项'
      }],
      name: "contentType",
      label: "\u4EFB\u52A1\u7C7B\u578B"
    }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
      type: "select",
      mode: "single",
      uniqueKey: "Task.contentType"
    })), this.renderKnowlodgeFormItems(), /*#__PURE__*/React__default.createElement(_Form.Item, {
      rules: [{
        required: true,
        message: '推送目标对象是必填项'
      }],
      name: "pushObject",
      label: "\u63A8\u9001\u76EE\u6807\u5BF9\u8C61"
    }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
      type: "select",
      mode: "single",
      uniqueKey: "Task.pushObject"
    })), this.renderUserFormItems(), /*#__PURE__*/React__default.createElement(_Form.Item, {
      rules: [{
        required: true,
        message: '推送频率是必填项'
      }],
      name: "pushFrequency",
      label: "\u63A8\u9001\u9891\u7387"
    }, /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect, {
      type: "select",
      mode: "single",
      uniqueKey: "Task.pushFrequency"
    })), /*#__PURE__*/React__default.createElement(_Form.Item, {
      rules: [{
        required: true,
        message: '推送时间是必填项'
      }],
      name: "pushFrequencyNote",
      label: "\u63A8\u9001\u65F6\u95F4"
    }, /*#__PURE__*/React__default.createElement(PushDate, null)), /*#__PURE__*/React__default.createElement(_Form.Item, {
      name: "releaseStatus",
      label: "\u53D1\u5E03\u72B6\u6001",
      valuePropName: "checked"
    }, reportBtnPermission ? /*#__PURE__*/React__default.createElement(_Switch, {
      checkedChildren: "\u5F00\u542F"
    }) : /*#__PURE__*/React__default.createElement(_Tooltip, {
      title: "\u65E0\u53D1\u5E03\u6743\u9650"
    }, /*#__PURE__*/React__default.createElement(_Switch, {
      disabled: true,
      checkedChildren: "\u5F00\u542F"
    })))));
  };
  return ModalForm;
}(Component);
var tableColumns = [{
  title: '任务类型',
  dataIndex: 'contentType',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE,
  render: function render(value) {
    return /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect_Display, {
      uniqueKey: "Task.contentType",
      value: value
    });
  }
}, {
  title: '任务标题',
  dataIndex: 'title',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE
}, {
  title: '宣教内容',
  dataIndex: 'description',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE,
  render: function render(value, rowData) {
    var _a, _b;
    if (_get(rowData, 'contentType') === 1) {
      return _get(rowData, 'knowledge.title');
    }
    if (_get(rowData, 'contentType') === 2) {
      return _get(rowData, 'video.title');
    }
    if (_get(rowData, 'contentType') === 3) {
      return _get(rowData, 'url');
    }
    if (_get(rowData, 'contentType') === 4) {
      return (_a = rowData === null || rowData === void 0 ? void 0 : rowData.questionnaireTitle) !== null && _a !== void 0 ? _a : (_b = rowData === null || rowData === void 0 ? void 0 : rowData.workQuestion) === null || _b === void 0 ? void 0 : _b.title;
    }
    return value;
  },
  ellipsis: true
}, {
  title: '推送目标对象',
  dataIndex: 'pregnantLimits',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  render: function render(value) {
    return /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect_Display, {
      uniqueKey: "Task.pushObject",
      value: value
    });
  }
}, {
  title: '推送详情',
  dataIndex: 'pregnantLimitsNote',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  ellipsis: true
}, {
  title: '推送时间',
  dataIndex: 'pushTime',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE,
  ellipsis: true
}, {
  title: '推送频率',
  dataIndex: 'pushFrequency',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE,
  render: function render(value) {
    return /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect_Display, {
      uniqueKey: "Task.pushFrequency",
      value: value
    });
  }
}, {
  title: '创建人',
  dataIndex: 'createUser',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE
}, {
  title: '创建时间',
  dataIndex: 'createDate',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  render: function render(value) {
    return formatTimeToStandard(value);
  }
}, {
  title: '发布状态',
  dataIndex: 'releaseStatus',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  render: function render(value) {
    return value === 1 ? /*#__PURE__*/React__default.createElement(_Badge, {
      status: "success",
      text: "\u5F00\u542F"
    }) : /*#__PURE__*/React__default.createElement(_Badge, {
      status: "error",
      text: "\u5173\u95ED"
    });
  }
}, {
  title: '发布者',
  dataIndex: 'releaseUser',
  width: APP_CONFIG.CELL_WIDTH_LARGE
}, {
  title: '运行状态',
  dataIndex: 'runStatus',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  render: function render(value) {
    return /*#__PURE__*/React__default.createElement(GeneralComponents_DictionarySelect_Display, {
      uniqueKey: "Task.runStatus",
      value: value
    });
  }
}, {
  title: '运行情况',
  dataIndex: 'runStatusNote',
  width: APP_CONFIG.CELL_WIDTH_LARGE,
  ellipsis: true
}];
var KnowledgesList = function (_super) {
  __extends(KnowledgesList, _super);
  function KnowledgesList(props) {
    var _this = _super.call(this, props) || this;
    _this.columns = __spreadArray(__spreadArray([], _this.props.tableColumns, true), [{
      title: '操作',
      showSorter: false,
      showFilter: false,
      fixed: 'right',
      width: 158,
      align: 'center',
      render: function render(value, rowData, index) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Button, {
          type: "link",
          size: "small",
          icon: /*#__PURE__*/React__default.createElement(EditOutlined, {
            className: "global-table-action-icon"
          }),
          onClick: _this.handleEdit(rowData)
        }, "\u7F16\u8F91"), /*#__PURE__*/React__default.createElement(_Divider, {
          type: "vertical"
        }), /*#__PURE__*/React__default.createElement(_Popconfirm, {
          title: "\u786E\u5B9A\u8981\u5220\u9664\u8FD9\u4E2A".concat(_get(_this.props, 'baseTitle'), "\u5417?"),
          onConfirm: _this.handleDelete(rowData),
          okText: "\u786E\u5B9A",
          cancelText: "\u53D6\u6D88"
        }, /*#__PURE__*/React__default.createElement(_Button, {
          type: "link",
          size: "small",
          danger: true,
          icon: /*#__PURE__*/React__default.createElement(DeleteOutlined, {
            className: "global-table-action-icon"
          })
        }, "\u5220\u9664")));
      }
    }], false);
    _this.renderOthersModal = function () {
      var ModalForm = _this.props.ModalForm;
      var _a = _this.state,
        visible = _a.visible,
        editable = _a.editable,
        id = _a.id;
      return visible && /*#__PURE__*/React__default.createElement(ModalForm, {
        visible: visible,
        editable: editable,
        id: id,
        onCancel: _this.handleCancel,
        onSearch: _this.handleSearch
      });
    };
    _this.state = __assign({}, _this.state);
    return _this;
  }
  KnowledgesList.defaultProps = {
    baseUrl: '/api/knowledge-tasks',
    baseTitle: '任务',
    needPagination: true,
    showQuery: true,
    showAdd: true,
    tableColumns: tableColumns,
    rowKey: 'id',
    Table: ProductsTable,
    Query: Query,
    ModalForm: ModalForm,
    otherTableProps: {
      scroll: {
        x: 1278
      }
    }
  };
  return KnowledgesList;
}(BaseListOld);
export { KnowledgesList as default };
//# sourceMappingURL=pages.tasks.list.js.map
