selfMeetingView.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <van-nav-bar
  3. fixed
  4. title="信息上报中心"
  5. left-text=""
  6. left-arrow
  7. @click-left="onClickLeft"
  8. />
  9. <van-loading size="16px" v-show="isLoading">加载中...</van-loading>
  10. <div class="main" v-show="!isLoading">
  11. <p class="title">私设聚会点上报</p>
  12. <div class="formArea">
  13. <p class="miniTitle">基础信息</p>
  14. <van-cell-group>
  15. <van-field
  16. v-model="inputForm.placeSelectName"
  17. center
  18. readonly
  19. label="地点:"
  20. placeholder="请填写参加地点"
  21. input-align="right"
  22. right-icon="arrow-down"
  23. @click="showArea = true"
  24. />
  25. <van-popup v-model:show="showArea" round position="bottom">
  26. <van-cascader
  27. v-model="cascaderValue"
  28. title="请选择所在地区"
  29. :options="options"
  30. @close="showArea = false"
  31. @finish="onFinish"
  32. :field-names="fieldNames"
  33. />
  34. </van-popup>
  35. </van-cell-group>
  36. <van-cell-group>
  37. <van-field
  38. v-model="inputForm.placeDel"
  39. center
  40. label="详细地址:"
  41. placeholder="请填写具体地址"
  42. input-align="right"
  43. right-icon="location"
  44. />
  45. </van-cell-group>
  46. <van-cell-group>
  47. <van-field
  48. v-model="inputForm.frequency"
  49. center
  50. label="频次:"
  51. placeholder="请填写频次"
  52. input-align="right"
  53. type="digit"
  54. />
  55. </van-cell-group>
  56. <van-cell-group>
  57. <van-field
  58. v-model="inputForm.partyTime"
  59. center
  60. readonly
  61. label="时间:"
  62. placeholder="请选择时间"
  63. input-align="right"
  64. right-icon="arrow-down"
  65. @click="showAct = true"
  66. />
  67. <van-popup v-model:show="showAct" round position="bottom">
  68. <van-picker-group
  69. :tabs="['选择日期', '选择时间']"
  70. next-step-text="下一步"
  71. @confirm="getTime"
  72. @cancel="showAct = false"
  73. >
  74. <van-date-picker v-model="currentDate" />
  75. <van-time-picker
  76. v-model="currentTime"
  77. :columns-type="columnsType"
  78. />
  79. </van-picker-group>
  80. </van-popup>
  81. </van-cell-group>
  82. <van-cell-group>
  83. <van-field
  84. v-model="inputForm.relatedPersons.name"
  85. center
  86. required
  87. label="相关人:"
  88. placeholder="请选择相关人"
  89. input-align="right"
  90. right-icon="arrow-down"
  91. @click="showPerson = true"
  92. />
  93. <van-dialog
  94. v-model:show="showPerson"
  95. title="选择人员"
  96. show-cancel-button
  97. @confirm="reselected"
  98. >
  99. <person-list @selected="selected" :type="1"></person-list>
  100. </van-dialog>
  101. </van-cell-group>
  102. <van-cell-group>
  103. <van-field label="内容:" label-align="top">
  104. <template #input>
  105. <wang-editor ref="contentEditor" v-model="inputForm.content" />
  106. </template>
  107. </van-field>
  108. </van-cell-group>
  109. </div>
  110. <div class="subbtn">
  111. <van-button type="primary" @click="submit">提交</van-button>
  112. <van-button type="default" hairline>取消</van-button>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import { ref, onMounted } from "vue";
  118. import personList from "../personList.vue";
  119. import tools from "@/api/sys/tools";
  120. import PrivatePartyPointService from "@/api/privateparty/PrivatePartyPointService";
  121. import UserManage from "@/api/user/UserManage";
  122. import { useRoute } from "vue-router";
  123. // 富文本编辑器
  124. import WangEditor from "@/components/editor/WangEditor";
  125. export default {
  126. components: { personList, WangEditor },
  127. setup() {
  128. // 加载
  129. let isLoading = ref(true);
  130. // 返回
  131. const onClickLeft = () => {
  132. history.back();
  133. };
  134. // 私设聚会点信息
  135. let inputForm = ref({
  136. id: "",
  137. place: "320900",
  138. placeSelectName: "盐城市",
  139. placeSelectType3: "320900",
  140. placeSelectType4: "",
  141. placeSelectType5: "",
  142. placeSelectType6: "",
  143. placeDel: "",
  144. frequency: "",
  145. partyTime: "",
  146. relatedPersons: {
  147. id: "",
  148. name: "",
  149. },
  150. content: "",
  151. state: "0",
  152. assessment: "0",
  153. });
  154. const contentEditor = ref(null);
  155. let route = useRoute();
  156. onMounted(() => {
  157. // 根据路由初始化
  158. if (route.query.id) {
  159. new PrivatePartyPointService()
  160. .queryById(route.query.id)
  161. .then((data) => {
  162. inputForm.value = data;
  163. let ids = data.relatedPersons.id.split(",");
  164. inputForm.value.relatedPersons.name = "";
  165. ids.forEach((item) => {
  166. new UserManage().queryById(item).then((data) => {
  167. inputForm.value.relatedPersons.name += data.name + ",";
  168. });
  169. });
  170. contentEditor.value.init(inputForm.value.content);
  171. isLoading.value = false;
  172. });
  173. } else {
  174. contentEditor.value.init(inputForm.value.content);
  175. isLoading.value = false;
  176. }
  177. });
  178. // 获取活动时间
  179. let showAct = ref(false);
  180. let currentDate = ref(["" + new Date().getFullYear(), "01", "01"]);
  181. let currentTime = ref(["00", "00", "00"]);
  182. const columnsType = ["hour", "minute", "second"];
  183. const getTime = () => {
  184. showAct.value = false;
  185. inputForm.value.partyTime = `${currentDate.value.join(
  186. "-"
  187. )} ${currentTime.value.join(":")}`;
  188. };
  189. // 相关人
  190. let showPerson = ref(false);
  191. let list = {
  192. value: [],
  193. type: "",
  194. };
  195. const selected = (val, type) => {
  196. list.value = val;
  197. list.type = type;
  198. };
  199. const reselected = () => {
  200. let ids = [];
  201. let names = [];
  202. if (list.type == 1) {
  203. list.value.forEach((item) => {
  204. ids.push(item.id);
  205. names.push(item.name);
  206. });
  207. inputForm.value.relatedPersons.id = ids.join(",");
  208. inputForm.value.relatedPersons.name = names.join(",");
  209. }
  210. };
  211. // 地区选择
  212. let showArea = ref(false);
  213. const cascaderValue = ref("");
  214. const fieldNames = {
  215. text: "name",
  216. value: "code",
  217. children: "children",
  218. };
  219. // 选项列表,children 代表子选项,支持多级嵌套
  220. let options = ref([]);
  221. new tools().treeData().then((res) => {
  222. options.value.push(res[0]);
  223. });
  224. // 全部选项选择完毕后,会触发 finish 事件
  225. const onFinish = ({ selectedOptions }) => {
  226. showArea.value = false;
  227. inputForm.value.placeSelectName = selectedOptions
  228. .map((option) => option.name)
  229. .join("/");
  230. };
  231. const submit = () => {
  232. isLoading.value = true;
  233. new PrivatePartyPointService().save(inputForm.value).then((res) => {
  234. if (res.status == 200 || res.statusText == "OK") {
  235. xm.showToast({
  236. message: res.data,
  237. });
  238. }
  239. onClickLeft();
  240. });
  241. };
  242. return {
  243. isLoading,
  244. inputForm,
  245. // 活动时间
  246. showAct,
  247. currentDate,
  248. currentTime,
  249. columnsType,
  250. getTime,
  251. // 返回
  252. onClickLeft,
  253. // 人员选择
  254. showPerson,
  255. selected,
  256. reselected,
  257. // 地区选择
  258. showArea,
  259. fieldNames,
  260. options,
  261. onFinish,
  262. cascaderValue,
  263. contentEditor,
  264. // change,
  265. submit,
  266. };
  267. },
  268. };
  269. </script>
  270. <style scoped>
  271. .van-dialog {
  272. width: 80%;
  273. top: 50%;
  274. }
  275. </style>