123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <van-nav-bar
- fixed
- title="信息上报中心"
- left-text=""
- left-arrow
- @click-left="onClickLeft"
- />
- <van-loading size="16px" v-show="isLoading">加载中...</van-loading>
- <div class="main" v-show="!isLoading">
- <p class="title">私设聚会点上报</p>
- <div class="formArea">
- <p class="miniTitle">基础信息</p>
- <van-cell-group>
- <van-field
- v-model="inputForm.placeSelectName"
- center
- readonly
- label="地点:"
- placeholder="请填写参加地点"
- input-align="right"
- right-icon="arrow-down"
- @click="showArea = true"
- />
- <van-popup v-model:show="showArea" round position="bottom">
- <van-cascader
- v-model="cascaderValue"
- title="请选择所在地区"
- :options="options"
- @close="showArea = false"
- @finish="onFinish"
- :field-names="fieldNames"
- />
- </van-popup>
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="inputForm.placeDel"
- center
- label="详细地址:"
- placeholder="请填写具体地址"
- input-align="right"
- right-icon="location"
- />
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="inputForm.frequency"
- center
- label="频次:"
- placeholder="请填写频次"
- input-align="right"
- type="digit"
- />
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="inputForm.partyTime"
- center
- readonly
- label="时间:"
- placeholder="请选择时间"
- input-align="right"
- right-icon="arrow-down"
- @click="showAct = true"
- />
- <van-popup v-model:show="showAct" round position="bottom">
- <van-picker-group
- :tabs="['选择日期', '选择时间']"
- next-step-text="下一步"
- @confirm="getTime"
- @cancel="showAct = false"
- >
- <van-date-picker v-model="currentDate" />
- <van-time-picker
- v-model="currentTime"
- :columns-type="columnsType"
- />
- </van-picker-group>
- </van-popup>
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="inputForm.relatedPersons.name"
- center
- required
- label="相关人:"
- placeholder="请选择相关人"
- input-align="right"
- right-icon="arrow-down"
- @click="showPerson = true"
- />
- <van-dialog
- v-model:show="showPerson"
- title="选择人员"
- show-cancel-button
- @confirm="reselected"
- >
- <person-list @selected="selected" :type="1"></person-list>
- </van-dialog>
- </van-cell-group>
- <van-cell-group>
- <van-field label="内容:" label-align="top">
- <template #input>
- <wang-editor ref="contentEditor" v-model="inputForm.content" />
- </template>
- </van-field>
- </van-cell-group>
- </div>
- <div class="subbtn">
- <van-button type="primary" @click="submit">提交</van-button>
- <van-button type="default" hairline>取消</van-button>
- </div>
- </div>
- </template>
-
- <script>
- import { ref, onMounted } from "vue";
- import personList from "../personList.vue";
- import tools from "@/api/sys/tools";
- import PrivatePartyPointService from "@/api/privateparty/PrivatePartyPointService";
- import UserManage from "@/api/user/UserManage";
- import { useRoute } from "vue-router";
- // 富文本编辑器
- import WangEditor from "@/components/editor/WangEditor";
- export default {
- components: { personList, WangEditor },
- setup() {
- // 加载
- let isLoading = ref(true);
- // 返回
- const onClickLeft = () => {
- history.back();
- };
- // 私设聚会点信息
- let inputForm = ref({
- id: "",
- place: "320900",
- placeSelectName: "盐城市",
- placeSelectType3: "320900",
- placeSelectType4: "",
- placeSelectType5: "",
- placeSelectType6: "",
- placeDel: "",
- frequency: "",
- partyTime: "",
- relatedPersons: {
- id: "",
- name: "",
- },
- content: "",
- state: "0",
- assessment: "0",
- });
- const contentEditor = ref(null);
- let route = useRoute();
- onMounted(() => {
- // 根据路由初始化
- if (route.query.id) {
- new PrivatePartyPointService()
- .queryById(route.query.id)
- .then((data) => {
- inputForm.value = data;
- let ids = data.relatedPersons.id.split(",");
- inputForm.value.relatedPersons.name = "";
- ids.forEach((item) => {
- new UserManage().queryById(item).then((data) => {
- inputForm.value.relatedPersons.name += data.name + ",";
- });
- });
- contentEditor.value.init(inputForm.value.content);
- isLoading.value = false;
- });
- } else {
- contentEditor.value.init(inputForm.value.content);
- isLoading.value = false;
- }
- });
- // 获取活动时间
- let showAct = ref(false);
- let currentDate = ref(["" + new Date().getFullYear(), "01", "01"]);
- let currentTime = ref(["00", "00", "00"]);
- const columnsType = ["hour", "minute", "second"];
- const getTime = () => {
- showAct.value = false;
- inputForm.value.partyTime = `${currentDate.value.join(
- "-"
- )} ${currentTime.value.join(":")}`;
- };
- // 相关人
- let showPerson = ref(false);
- let list = {
- value: [],
- type: "",
- };
- const selected = (val, type) => {
- list.value = val;
- list.type = type;
- };
- const reselected = () => {
- let ids = [];
- let names = [];
- if (list.type == 1) {
- list.value.forEach((item) => {
- ids.push(item.id);
- names.push(item.name);
- });
- inputForm.value.relatedPersons.id = ids.join(",");
- inputForm.value.relatedPersons.name = names.join(",");
- }
- };
- // 地区选择
- let showArea = ref(false);
- const cascaderValue = ref("");
- const fieldNames = {
- text: "name",
- value: "code",
- children: "children",
- };
- // 选项列表,children 代表子选项,支持多级嵌套
- let options = ref([]);
- new tools().treeData().then((res) => {
- options.value.push(res[0]);
- });
- // 全部选项选择完毕后,会触发 finish 事件
- const onFinish = ({ selectedOptions }) => {
- showArea.value = false;
- inputForm.value.placeSelectName = selectedOptions
- .map((option) => option.name)
- .join("/");
- };
- const submit = () => {
- isLoading.value = true;
- new PrivatePartyPointService().save(inputForm.value).then((res) => {
- if (res.status == 200 || res.statusText == "OK") {
- xm.showToast({
- message: res.data,
- });
- }
- onClickLeft();
- });
- };
- return {
- isLoading,
- inputForm,
- // 活动时间
- showAct,
- currentDate,
- currentTime,
- columnsType,
- getTime,
- // 返回
- onClickLeft,
- // 人员选择
- showPerson,
- selected,
- reselected,
- // 地区选择
- showArea,
- fieldNames,
- options,
- onFinish,
- cascaderValue,
- contentEditor,
- // change,
- submit,
- };
- },
- };
- </script>
-
- <style scoped>
- .van-dialog {
- width: 80%;
- top: 50%;
- }
- </style>
|