¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <FYForm |
| | | ref="formRef" |
| | | :form-info="formInfo" |
| | | :rules="rules" |
| | | :useCancel="true" |
| | | @submit="submit" |
| | | @cancel="cancel" |
| | | > |
| | | <template #form-item="{ formObj }"> |
| | | <el-form-item label="ä»»å¡åç§°" prop="name"> |
| | | <el-input disabled v-model="formObj.name" placeholder="ä»»å¡åç§°" /> |
| | | </el-form-item> |
| | | <el-form-item label="åºæ¯å°å" prop="name"> |
| | | <el-input |
| | | disabled |
| | | v-model="formObj.scenseaddress" |
| | | placeholder="åºæ¯å°å" |
| | | /> |
| | | </el-form-item> |
| | | <FYOptionTime |
| | | label="è®¡åæ¶é´" |
| | | prop="planstarttime" |
| | | :initValue="false" |
| | | type="date" |
| | | v-model:value="formObj.planstarttime" |
| | | @change="handleTimeChange" |
| | | ></FYOptionTime> |
| | | <el-form-item label="æ§è¡äºº" prop="_executors"> |
| | | <el-select |
| | | v-model="formObj._executors" |
| | | multiple |
| | | clearable |
| | | collapse-tags |
| | | placeholder="éæ©æ§è¡äºº" |
| | | :max-collapse-tags="3" |
| | | style="width: 300px" |
| | | > |
| | | <el-option |
| | | v-for="s in executorOptions" |
| | | :key="s.value" |
| | | :label="s.label" |
| | | :value="s.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </template> |
| | | </FYForm> |
| | | </template> |
| | | <script setup> |
| | | import { ref, computed, onMounted, reactive } from 'vue'; |
| | | import subtaskApi from '@/api/fysp/subtaskApi'; |
| | | import userApi from '@/api/fysp/userApi'; |
| | | import dayjs from 'dayjs'; |
| | | |
| | | const props = defineProps({ |
| | | //åºæ¬ä¿¡æ¯ |
| | | modelValue: Object, |
| | | //æ¯å建æè
æ´æ° |
| | | create: Boolean |
| | | }); |
| | | |
| | | const emit = defineEmits(['submit', 'cancel', 'update:modelValue']); |
| | | |
| | | const formRef = ref(null); |
| | | // 任塿§è¡äººé项 |
| | | const executorOptions = ref([]); |
| | | const formInfo = computed(() => { |
| | | return { |
| | | ...props.modelValue, |
| | | _executors: props.modelValue |
| | | ? props.modelValue.executorguids.split('#') |
| | | : [] |
| | | }; |
| | | }); |
| | | |
| | | const rules = reactive({ |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message: 'åºæ¯åç§°ä¸è½ä¸ºç©º', |
| | | trigger: 'blur' |
| | | } |
| | | ], |
| | | _scenetype: [ |
| | | { |
| | | required: true, |
| | | message: 'åºæ¯ç±»åä¸è½ä¸ºç©º', |
| | | trigger: 'change' |
| | | } |
| | | ] |
| | | }); |
| | | |
| | | function handleTimeChange(time) { |
| | | formRef.value.formObj.planendtime = dayjs(time).endOf('day').set('millisecond', 0) |
| | | } |
| | | |
| | | function getExecutors(data) { |
| | | const ids = []; |
| | | const uNames = []; |
| | | const rNames = []; |
| | | executorOptions.value.forEach((e) => { |
| | | const index = data._executors.indexOf(e.value); |
| | | if (index != -1) { |
| | | ids.push(e.data.guid); |
| | | uNames.push(e.data.acountname); |
| | | rNames.push(e.data.realname); |
| | | } |
| | | }); |
| | | return { |
| | | id: ids.join('#'), |
| | | uName: uNames.join('#'), |
| | | rName: rNames.join('#') |
| | | }; |
| | | } |
| | | |
| | | // å建æ°åºæ¯ |
| | | function createScene(v, success, fail) { |
| | | // return sceneApi |
| | | // .createScene(v) |
| | | // .then(() => { |
| | | // emit('onSubmit', v); |
| | | // success(); |
| | | // }) |
| | | // .catch((err) => { |
| | | // fail(err); |
| | | // }); |
| | | } |
| | | // æ´æ°åºæ¯ |
| | | function updateScene(v, success, fail) { |
| | | return subtaskApi |
| | | .adjustSubtask(v) |
| | | .then(() => { |
| | | emit('update:modelValue', v) |
| | | emit('submit', v); |
| | | success(); |
| | | }) |
| | | .catch((err) => { |
| | | fail(err); |
| | | }); |
| | | } |
| | | function submit(v, success, fail) { |
| | | const executors = getExecutors(v.value); |
| | | v.value.executorguids = executors.id |
| | | v.value.executorusernames = executors.uName |
| | | v.value.executorrealtimes = executors.rName |
| | | return props.create |
| | | ? createScene(v.value, success, fail) |
| | | : updateScene(v.value, success, fail); |
| | | } |
| | | function cancel() { |
| | | emit('cancel'); |
| | | } |
| | | |
| | | function initOptions() { |
| | | userApi.getUserByType(1).then((res) => { |
| | | executorOptions.value = res.map((v) => { |
| | | return { |
| | | label: v.realname, |
| | | value: v.guid, |
| | | data: v |
| | | }; |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | initOptions(); |
| | | }); |
| | | </script> |