|
@@ -72,7 +72,6 @@
|
|
|
name="visitTime"
|
|
|
label="拜访时间"
|
|
|
placeholder="请选择"
|
|
|
- :disabled="addOrEdit"
|
|
|
:rules="[{ required: true, message: '' }]"
|
|
|
@click="showPickerClick('visitTime')"
|
|
|
>
|
|
@@ -139,6 +138,15 @@
|
|
|
@cancel="showPicker = false"
|
|
|
/>
|
|
|
</van-popup>
|
|
|
+ <!-- 时间选择器 -->
|
|
|
+ <van-popup
|
|
|
+ v-model:show="timeShowPicker"
|
|
|
+ destroy-on-close
|
|
|
+ position="bottom"
|
|
|
+ :style="{ height: '50%' }"
|
|
|
+ >
|
|
|
+ <van-time-picker v-model="currentTime" title="选择时间" @confirm="timeConfirm" />
|
|
|
+ </van-popup>
|
|
|
<!-- 客户选择 -->
|
|
|
<van-popup
|
|
|
v-model:show="customerShowPicker"
|
|
@@ -195,18 +203,21 @@
|
|
|
import { ref } from "vue";
|
|
|
import { useLifecycle } from "@hooks/useCommon.js";
|
|
|
import dayjs from "dayjs";
|
|
|
-import { GET_ALL_CUSTOMERS, RETRIEVE_DICTIONARY_ENTRIES } from "@hooks/useApi";
|
|
|
+import { GET_ALL_CUSTOMERS, RETRIEVE_DICTIONARY_ENTRIES, PLAN_TO_ADD_EDITORS } from "@hooks/useApi";
|
|
|
+import useToast from "@hooks/useToast"
|
|
|
import requests from "@common/requests";
|
|
|
import useRouterStore from "@store/useRouterStore.js";
|
|
|
import useFixedData from "@store/useFixedData.js";
|
|
|
import PullDownSelector from "@components/common/pullDownSelector.vue";
|
|
|
|
|
|
const router = useRouterStore();
|
|
|
+const { toastText, toastSuccess, toastFail, toastLoading } = useToast()
|
|
|
const fixedData = useFixedData();
|
|
|
const form = ref({});
|
|
|
const addEditFormRef = ref()
|
|
|
const submitLoading = ref(false);
|
|
|
const showPicker = ref(false);
|
|
|
+const timeShowPicker = ref(false);
|
|
|
const customerShowPicker = ref(false);
|
|
|
const personnelShowPicker = ref(false);
|
|
|
const visitShowPicker = ref(false);
|
|
@@ -214,21 +225,26 @@ const remindShowPicker = ref(false);
|
|
|
const customerAllList = ref([]);
|
|
|
const purposeOfVisitList = ref([]); // 拜访目的
|
|
|
const reminderTimeList = ref([]); // 提醒时间
|
|
|
-const dateSelectionValue = dayjs(new Date()).format("YYYY-MM-DD").split("-");
|
|
|
+const dateSelectionValue = ref(dayjs(new Date()).format("YYYY-MM-DD").split("-"));
|
|
|
+const currentTime = ref(dayjs(new Date()).format("HH:mm").split(":"));
|
|
|
const dateSelectionFiled = ref("");
|
|
|
const addOrEdit = ref(true); // true 编辑,false 新增
|
|
|
+const addOrEditRow = ref({})
|
|
|
|
|
|
function onSubmit() {
|
|
|
addEditFormRef.value.validate().then((res) => {
|
|
|
const data = addEditFormRef.value.getValues()
|
|
|
+ if(addOrEdit.value) {
|
|
|
+ data.planId = addOrEditRow.value.id
|
|
|
+ }
|
|
|
submitLoading.value = true
|
|
|
- requests.post(PLAN_TO_ADD_EDITORS, { ...data }).then(() => {
|
|
|
+ requests.post(PLAN_TO_ADD_EDITORS, { ...data }).then((res) => {
|
|
|
toastSuccess("保存成功")
|
|
|
setTimeout(() => {
|
|
|
history.back();
|
|
|
}, 2000)
|
|
|
}).catch(err => {
|
|
|
- toastFail(`保存失败:${err.message}`)
|
|
|
+ toastFail(`保存失败:${err.msg}`)
|
|
|
}).finally(() => {
|
|
|
submitLoading.value = false
|
|
|
})
|
|
@@ -264,21 +280,29 @@ function remindSelectChange(value, label) {
|
|
|
}
|
|
|
|
|
|
function showPickerConfirm({ selectedValues }) {
|
|
|
- form.value[dateSelectionFiled.value] = selectedValues.join("-");
|
|
|
+ form.value[dateSelectionFiled.value] = `${selectedValues.join("-")} ${currentTime.value.join(":")}`
|
|
|
showPicker.value = false;
|
|
|
+ timeShowPicker.value = true;
|
|
|
+}
|
|
|
+
|
|
|
+function timeConfirm({ selectedValues }) {
|
|
|
+ form.value[dateSelectionFiled.value] = `${dateSelectionValue.value.join("-")} ${selectedValues.join(":")}`
|
|
|
+ timeShowPicker.value = false;
|
|
|
}
|
|
|
|
|
|
function showPickerClick(filed) {
|
|
|
- (dateSelectionValue.value = form.value[filed]
|
|
|
- ? form.value[filed]
|
|
|
- : dayjs(new Date()).format("YYYY-MM-DD").split("-")),
|
|
|
- (dateSelectionFiled.value = filed);
|
|
|
+ const dateTimeVal = form.value[filed] ? form.value[filed] : new Date()
|
|
|
+ dateSelectionValue.value = dayjs(dateTimeVal).format("YYYY-MM-DD").split("-")
|
|
|
+ currentTime.value = dayjs(dateTimeVal).format("HH:mm").split(":")
|
|
|
+ dateSelectionFiled.value = filed;
|
|
|
showPicker.value = true;
|
|
|
}
|
|
|
|
|
|
function processingDataSource(data) {
|
|
|
const row = JSON.parse(data.row);
|
|
|
addOrEdit.value = Object.keys(row).length > 0 ? true : false;
|
|
|
+ addOrEditRow.value = row
|
|
|
+ form.value = row
|
|
|
obtainThePurposeOfTheVisit();
|
|
|
getReminderTime();
|
|
|
getAllCustomers();
|