123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <a-form-model-item
- v-if="lx === 'type'"
- ref="model"
- :rules="rules"
- :label="null"
- prop="empowerType"
- >
- <a-select v-model="model.empowerType" @change="changee">
- <a-select-option v-for="(key, i) in field.attr.selectListItem" :key="i" :value="key.value">
- {{ key.label }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item
- v-else-if="lx === 'stime'"
- ref="model"
- :rules="rules"
- :label="null"
- prop="startDate"
- >
- <a-date-picker
- :key="modelKey"
- v-model="model.startDate"
- :disabled="disabled"
- :disabled-date="disabledStartDate"
- @change="changest"
- />
- </a-form-model-item>
- <a-form-model-item v-else ref="model" :label="null" :rules="rules" prop="endDate">
- <a-date-picker
- :key="modelKey"
- v-model="model.endDate"
- :disabled="disabled"
- :disabled-date="disabledEndDate"
- @change="changeet"
- />
- </a-form-model-item>
- </template>
- <script>
- import moment from 'moment'
- export default {
- name: 'AuditWarrantInput',
- metaInfo: {
- title: 'AuditWarrantInput',
- },
- props: {
- value: {
- type: Object,
- default: null,
- },
- field: {
- type: Object,
- default: () => {},
- },
- index: {
- type: Number,
- default: -1,
- },
- lx: {
- type: String,
- default: '',
- },
- data: {
- type: String,
- default: 'udata',
- },
- },
- data() {
- return {
- modelKey: 0,
- time: '',
- model: { empowerType: '', startDate: '', endDate: '' },
- disabled:
- this.value.empowerType === '1' ||
- this.value.empowerType === '2' ||
- this.empowerType === '2',
- rules: [{ required: true, trigger: ['change', 'blur'] }],
- empowerType: '',
- startDate: '',
- endDate: '',
- }
- },
- watch: {
- empowerType(val) {
- this.isLastDay()
- this.$emit('change', this.model.empowerType, this.field, this.index, this.lx, this.data)
- this.$refs.model.validate('blur')
- },
- startDate() {
- this.$emit('change', this.model.startDate, this.field, this.index, this.lx, this.data)
- this.$refs.model.validate('blur')
- },
- endDate() {
- this.$emit('change', this.model.endDate, this.field, this.index, this.lx, this.data)
- this.$refs.model.validate('blur')
- },
- },
- created() {
- if (this.value !== null) {
- if (this.lx === 'type') {
- if (this.value.empowerType) {
- this.model.empowerType = this.value.empowerType
- }
- } else if (this.lx === 'stime') {
- if (this.value.startDate) {
- this.model.startDate = this.value.startDate
- if (this.value.empowerType === '1') {
- this.disabled = true
- }
- }
- } else if (this.lx === 'etime') {
- if (this.value.endDate) {
- this.model.endDate = this.value.endDate
- if (this.value.empowerType === '1') {
- this.disabled = true
- }
- }
- }
- }
- },
- methods: {
- disabledStartDate(startDate) {
- const finishDate = this.time
- if (!startDate || !finishDate) {
- return false
- }
- return startDate.valueOf() > finishDate.valueOf()
- },
- disabledEndDate(finishDate) {
- const startDate = this.time
- if (!finishDate || !startDate) {
- return false
- }
- return startDate.valueOf() >= finishDate.valueOf()
- },
- changee(value) {
- this.empowerType = value
- this.isLastDay()
- },
- changest(value) {
- this.startDate = value
- this.isLastDay()
- },
- changeet(value) {
- this.endDate = value
- this.isLastDay()
- },
- isLastDay() {
- // if (this.empowerType === '2') {
- // const now = moment()
- // const end = moment().endOf('year')
- // this.startDate = now
- // this.endDate = end
- // this.model.startDate = now
- // this.model.endDate = end
- // }
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- </style>
|