wupengfei
14 小时以前 a686faf1c2132f55e40119df28ce9f6e46206b74
src/views/EmploymentManage/components/AddOrEditEmploymentView.vue
@@ -5,14 +5,34 @@
        <ProForm :model="form" ref="productFormRef" label-width="110px" :is-read="isDetail">
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="任务名称:" prop="name">
              <ProFormItemV2
                label="任务名称:"
                prop="name"
                :check-rules="[{ message: '请输入任务名称' }]"
              >
                <ProFormText v-model.trim="form.name" placeholder="请输入任务名称" />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="服务费:" prop="billingMethod">
              <ProFormItemV2
                label="服务费:"
                prop="billingMethod"
                :check-rules="[
                  {
                    validator: (rule, value, callback) => {
                      if (!form.billingMethod) {
                        callback(new Error('请选择服务费类型'));
                      }
                      if (!form.serviceFee) {
                        callback(new Error('请输入服务费'));
                      }
                      callback();
                    },
                  },
                ]"
              >
                <RadioWithExtra
                  v-model="form.billingMethod"
                  :value-enum="EnumBillingMethodText"
@@ -33,12 +53,34 @@
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="结算方式:" prop="settlementCycle">
              <ProFormItemV2
                label="结算方式:"
                prop="settlementCycle"
                :check-rules="[{ message: '请选择结算方式' }]"
              >
                <ProFormRadio
                  v-model="form.settlementCycle"
                  :value-enum="EnumSettlementCycleText"
                  :button-style="false"
                ></ProFormRadio>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2
                label="结算日期:"
                prop="settlementCycle"
                :check-rules="[{ message: '请选择结算日期' }]"
                class="settlement-cycle-date-form-item"
              >
                {{ EnumSettlementCycleDateText[form.settlementCycle] }}
                <ProFormSelect
                  v-model="form.settlementCycle"
                  :value-enum="[]"
                  :button-style="false"
                ></ProFormSelect>
                {{ '日结算' }}
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
@@ -63,17 +105,37 @@
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="年龄范围:" prop="ageRange" class="form-age-range">
              <ProFormItemV2
                label="年龄范围:"
                prop="ageRange"
                class="form-age-range"
                :check-rules="[
                  {
                    validator: (rule, value, callback) => {
                      if (!form.ageMinLimit) {
                        callback(new Error('请输入年龄要求'));
                      }
                      if (!form.ageMaxLimit) {
                        callback(new Error('请输入年龄要求'));
                      }
                      if (Number(form.ageMaxLimit) <= Number(form.ageMinLimit)) {
                        callback(new Error('最大年龄不能小于最小年龄'));
                      }
                      callback();
                    },
                  },
                ]"
              >
                <ProFormInputNumber
                  :controls="false"
                  :min="1"
                  :min="0"
                  v-model="form.ageMinLimit"
                  placeholder="请输入"
                ></ProFormInputNumber>
                <div class="form-input-separator">至</div>
                <ProFormInputNumber
                  :controls="false"
                  :min="1"
                  :min="0"
                  v-model="form.ageMaxLimit"
                  placeholder="请输入"
                ></ProFormInputNumber>
@@ -82,13 +144,14 @@
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="性别要求:" prop="genderLimit">
              <ProFormItemV2
                label="性别要求:"
                prop="genderLimit"
                :check-rules="[{ message: '请选择性别要求' }]"
              >
                <ProFormRadio
                  v-model="form.genderLimit"
                  :value-enum="EnumUserGenderTextForEdit"
                  show-all-btn
                  :all-btn-label="'不限'"
                  :allBtnValue="0"
                ></ProFormRadio>
              </ProFormItemV2>
            </ProFormColItem>
@@ -114,7 +177,11 @@
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="任务地点:" prop="weMapInfo">
              <ProFormItemV2
                label="任务地点:"
                prop="weMapInfo"
                :check-rules="[{ message: '请选择任务地点', type: 'weMap' }]"
              >
                <WeMap v-if="!isDetail" v-model="form.weMapInfo" />
                <div v-else>
                  {{
@@ -128,20 +195,29 @@
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="详细地址:" prop="addressDetail">
              <ProFormItemV2
                label="详细地址:"
                prop="addressDetail"
                :check-rules="[{ message: '请输入详细地址' }]"
              >
                <ProFormText v-model.trim="form.addressDetail" placeholder="请输入详细地址" />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="12">
              <ProFormItemV2 label="任务时间:" prop="time">
              <ProFormItemV2
                label="任务时间:"
                prop="time"
                :check-rules="[{ message: '请选择任务时间', type: 'array' }]"
              >
                <ProFormDatePicker
                  v-model="form.time"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :disabled-date="disabledDate"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
@@ -169,6 +245,7 @@
  ProFormRadio,
  ProFormDatePicker,
  ProFormCheckbox,
  ProFormSelect,
} from '@bole-core/components';
import { FormInstance, ModelValueType } from 'element-plus';
import { Message } from '@bole-core/core';
@@ -180,8 +257,9 @@
  EnumBillingMethodText,
  EnumBillingMethodUnitText,
  EnumSettlementCycleText,
  EnumSettlementCycleDateText,
} from '@/constants';
import { format } from '@/utils';
import { format, FormValidator } from '@/utils';
import dayjs from 'dayjs';
defineOptions({
@@ -194,6 +272,10 @@
const route = useRoute();
const id = route.params.id as string;
const isEdit = !!id;
function disabledDate(time: Date) {
  return dayjs(time).isBefore(dayjs(), 'day');
}
const eventContext = useGlobalEventContext();
@@ -215,12 +297,12 @@
const form = reactive({
  name: '',
  billingMethod: '' as any as EnumBillingMethod,
  serviceFee: 0,
  settlementCycle: '' as any as EnumSettlementCycle,
  billingMethod: EnumBillingMethod.Month,
  serviceFee: null,
  settlementCycle: EnumSettlementCycle.Month,
  benefits: [] as string[],
  ageMinLimit: 0,
  ageMaxLimit: 0,
  ageMinLimit: null,
  ageMaxLimit: null,
  genderLimit: 0 as any as EnumUserGender,
  credentialLimits: [] as string[],
  time: [] as unknown as ModelValueType,
@@ -269,7 +351,7 @@
function handleBack() {
  closeViewPush(route, {
    name: 'EmploymentManageList',
    name: 'TaskManageList',
  });
}
const productFormRef = ref<FormInstance>();
@@ -311,7 +393,7 @@
    let res = await taskServices.saveTaskInfo(params);
    if (res) {
      Message.successMessage('操作成功');
      eventContext.emit(isEdit ? 'employment:edit' : 'employment:add');
      eventContext.emit(isEdit ? 'taskManage:edit' : 'taskManage:add');
      handleBack();
    }
  } catch (error) {}
@@ -361,5 +443,20 @@
      width: auto;
    }
  }
  .settlement-cycle-date-form-item {
    color: inherit;
    .el-form-item__content {
      flex-wrap: nowrap;
      .el-select {
        margin: 0 20px;
        width: auto;
        min-width: 0;
        flex: 1;
      }
    }
  }
}
</style>