ReligiousPeopleReportView.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <van-nav-bar fixed title="信教异常群众信息上报" left-text="" left-arrow @click-left="onClickLeft" />
  3. <van-loading size="16px" v-if="isLoading">加载中...</van-loading>
  4. <div class="main" v-if="!isLoading">
  5. <!-- <p class="title">信教异常群众上报</p> -->
  6. <van-form class="formArea" @submit="submit" show-error :show-error-message="false" validate-trigger="onChange">
  7. <!-- <p class="miniTitle">基础信息</p> -->
  8. <van-cell-group>
  9. <van-field v-model="religiousType" center readonly label="宗教类型:" placeholder="请选择宗教类型" input-align="right"
  10. right-icon="arrow-down" @click="showPlace = true" />
  11. <van-popup v-model:show="showPlace" round position="bottom">
  12. <van-picker title="宗教类型" :columns="$dictUtils.getDictList('hs_religion_type')" :columns-field-names="{
  13. text: 'label',
  14. value: 'value'
  15. }" @cancel="showPlace = false" @confirm="getType" />
  16. </van-popup>
  17. </van-cell-group>
  18. <van-cell-group>
  19. <van-field v-model="inputForm.abnormalName" center label="异常人员:" placeholder="请填写异常人员姓名" input-align="right" />
  20. </van-cell-group>
  21. <van-cell-group>
  22. <van-field v-model="inputForm.abnormalIdcar" center label="身份证号:" placeholder="请填写身份证号" input-align="right"
  23. type="digit" />
  24. </van-cell-group>
  25. <van-cell-group>
  26. <van-field v-model="inputForm.abnormalPhone" center label="手机号:" placeholder="请填写手机号" input-align="right"
  27. type="tel" />
  28. </van-cell-group>
  29. <van-cell-group>
  30. <van-field name="radio" label="性别:" input-align="right">
  31. <template #input>
  32. <van-radio-group v-model="inputForm.sex" direction="horizontal">
  33. <van-radio name="1">男</van-radio>
  34. <van-radio name="2">女</van-radio>
  35. </van-radio-group>
  36. </template>
  37. </van-field>
  38. </van-cell-group>
  39. <van-cell-group>
  40. <van-field v-model="inputForm.nativePlace" center readonly label="籍贯:" placeholder="请选择籍贯" input-align="right"
  41. right-icon="arrow-down" @click="showArea = true" />
  42. <van-popup v-model:show="showArea" round position="bottom">
  43. <van-picker title="籍贯选择" :columns="options" :columns-field-names="customFieldName" @cancel="showArea = false"
  44. @confirm="onFinish2" />
  45. </van-popup>
  46. </van-cell-group>
  47. <van-cell-group>
  48. <van-field v-model="inputForm.currentResidence" center readonly label="现居地:" placeholder="请选择现居地"
  49. input-align="right" right-icon="arrow-down" @click="showCurrentArea = true" />
  50. <van-popup v-model:show="showCurrentArea" round position="bottom">
  51. <van-picker title="现居地选择" :columns="options" :columns-field-names="customFieldName"
  52. @cancel="showCurrentArea = false" @confirm="onFinish" />
  53. </van-popup>
  54. </van-cell-group>
  55. <van-cell-group>
  56. <van-field v-model="inputForm.currentResidenceDetail" center label="现居地详情:" placeholder="请填写现居地详情"
  57. input-align="right">
  58. <template #right-icon>
  59. <van-icon name="location" @click="getLocation" />
  60. </template>
  61. </van-field>
  62. </van-cell-group>
  63. <van-cell-group>
  64. <div class="rowTextArea">
  65. <van-field v-model="inputForm.abnormalBehavior" required :rules="[{ required: true }]" placeholder="请填写异常行为"
  66. center rows="2" type="textarea" label="异常行为:" label-align="top" />
  67. </div>
  68. </van-cell-group>
  69. <van-cell-group>
  70. <van-field name="uploader" required :rules="[{ required: true }]" label="证据上传:">
  71. <template #input>
  72. <van-uploader readonly v-model="fileList" :max-count="5" accept="" :preview-full-image="false"
  73. :before-delete="deleteRead" @click-upload="chooseImg">
  74. <van-button>上传文件(可添加图片、音、视频和文本等)</van-button>
  75. </van-uploader>
  76. </template>
  77. </van-field>
  78. </van-cell-group>
  79. <div class="subbtn">
  80. <van-button type="primary" native-type="submit">提交</van-button>
  81. <van-button type="default" hairline @click="onClickLeft">取消</van-button>
  82. </div>
  83. </van-form>
  84. </div>
  85. </template>
  86. <script>
  87. import { ref, onMounted, getCurrentInstance } from "vue";
  88. import { useCascaderAreaData } from "@vant/area-data";
  89. import ReligiousPeopleReportService from "@/api/differentbelievers/ReligiousPeopleReportService";
  90. import { useRoute } from "vue-router";
  91. import tools from "@/api/sys/tools";
  92. // 图片路径
  93. import $base from "@/utils/config";
  94. export default {
  95. setup() {
  96. // 返回
  97. const onClickLeft = () => {
  98. history.back();
  99. };
  100. // 加载
  101. let isLoading = ref(true);
  102. // 异常人员信息
  103. const inputForm = ref({
  104. id: '',
  105. abnormalName: '',
  106. religiousType: '',
  107. information: '',
  108. abnormalIdcar: '',
  109. sex: '',
  110. abnormalPhone: '',
  111. nativePlace: '',
  112. currentResidence: '',
  113. currentResidenceDetail: '',
  114. abnormalBehavior: '',
  115. state: '0',
  116. assessment: '0',
  117. currentResidenceId: '',
  118. currentResidenceLevel1: '',
  119. currentResidenceLevel2: '',
  120. currentResidenceLevel3: '',
  121. currentResidenceLevel4: '',
  122. currentResidenceLevel5: '',
  123. currentResidenceLevel6: ''
  124. });
  125. const current = getCurrentInstance()
  126. // 根据路由初始化
  127. let route = useRoute();
  128. onMounted(() => {
  129. //籍贯接口
  130. new tools().nativePlace().then((res) => {
  131. options.value.push(...res);
  132. });
  133. if (route.query.id) {
  134. new ReligiousPeopleReportService()
  135. .queryById(route.query.id)
  136. .then((data) => {
  137. inputForm.value = data;
  138. religiousType.value = current.appContext.config.globalProperties.$dictUtils.getDictLabel('hs_religion_type', inputForm.value.religiousType)
  139. inputForm.value.information.split("|").forEach((item) => {
  140. if (item.trim().length > 0) {
  141. fileupList.value.push({
  142. name: decodeURIComponent(
  143. item.substring(item.lastIndexOf("/") + 1)
  144. ),
  145. url: $base + item.replace("程序附件//", "程序附件/"),
  146. id: item.replace("程序附件//", "程序附件/")
  147. });
  148. fileList.value.push({
  149. name: decodeURIComponent(
  150. item.substring(item.lastIndexOf("/") + 1)
  151. ),
  152. url: $base + item.replace("程序附件//", "程序附件/"),
  153. id: item.replace("程序附件//", "程序附件/")
  154. });
  155. }
  156. });
  157. isLoading.value = false;
  158. });
  159. } else {
  160. isLoading.value = false;
  161. }
  162. });
  163. // 现居地选择
  164. const showCurrentArea = ref(false);
  165. const customFieldName = {
  166. text: "name",
  167. value: "id",
  168. };
  169. // 选项列表,children 代表子选项,支持多级嵌套
  170. const options = ref([]);
  171. // 全部选项选择完毕后,会触发 finish 事件
  172. const onFinish = ({ selectedOptions }) => {
  173. showCurrentArea.value = false;
  174. console.log(selectedOptions);
  175. inputForm.value.currentResidence = selectedOptions
  176. .map((option) => option.name)
  177. .join("/");
  178. inputForm.value.currentResidenceId = selectedOptions
  179. .map((option) => option.id)
  180. .join("/");
  181. inputForm.value.currentResidenceLevel1 = selectedOptions[0] ? selectedOptions[0].id : ''
  182. inputForm.value.currentResidenceLevel2 = selectedOptions[1] ? selectedOptions[1].id : ''
  183. inputForm.value.currentResidenceLevel3 = selectedOptions[2] ? selectedOptions[2].id : ''
  184. inputForm.value.currentResidenceLevel4 = selectedOptions[3] ? selectedOptions[3].id : ''
  185. inputForm.value.currentResidenceLevel5 = selectedOptions[4] ? selectedOptions[4].id : ''
  186. inputForm.value.currentResidenceLevel6 = selectedOptions[5] ? selectedOptions[5].id : ''
  187. }
  188. const getLocation = () => {
  189. xm.getLocation().then(data => {
  190. inputForm.value.currentResidenceDetail = data.POIName;
  191. })
  192. }
  193. // 籍贯选择
  194. let showArea = ref(false);
  195. // 全部选项选择完毕后,会触发 finish 事件
  196. const onFinish2 = ({ selectedOptions }) => {
  197. showArea.value = false;
  198. inputForm.value.nativePlace = selectedOptions
  199. .map((option) => option.name)
  200. .join("/");
  201. };
  202. const getType = ({ selectedOptions }) => {
  203. showPlace.value = false;
  204. inputForm.value.religiousType = selectedOptions[0].value;
  205. religiousType.value = selectedOptions[0].label
  206. };
  207. // 文件上传
  208. let fileList = ref([]);
  209. let fileupList = ref([]);
  210. const chooseImg = () => {
  211. xm.chooseFile({
  212. count: 1,
  213. name: "file",
  214. url: $base + `/sys/file/webupload/upload?uploadPath=differentbelievers/religiousPeopleReport`,
  215. headers: { 'Content-Type': 'multipart/form-data', "token": window.localStorage.getItem('MZ_TOKEN') },
  216. }).then(res => {
  217. let data = res[0].data
  218. data.name = decodeURIComponent(
  219. data.id.substring(data.url.lastIndexOf("/") + 1)
  220. );
  221. data.url = $base + data.url;
  222. fileupList.value.push(data);
  223. fileList.value.push(data)
  224. })
  225. }
  226. // 删除文件
  227. const deleteRead = (file) => {
  228. //删除文件操作
  229. for (let index = 0; index < fileList.value.length; index++) {
  230. if (file.id == fileList.value[index].id) {
  231. fileList.value.splice(index, 1);
  232. if (fileupList.value[index]) {
  233. let delurl = fileupList.value[index].url;
  234. new tools().uploadFiledelete("", delurl).then(({ data }) => { });
  235. fileupList.value.splice(index, 1);
  236. }
  237. }
  238. }
  239. };
  240. // 提交数据
  241. const submit = () => {
  242. isLoading.value = true;
  243. //保存前附件处理
  244. inputForm.value.information = fileupList.value
  245. .map((option) => option.id)
  246. .join("|");
  247. new ReligiousPeopleReportService().save(inputForm.value).then((res) => {
  248. if (res.status == 200 || res.statusText == "OK") {
  249. xm.showToast({
  250. message: res.data,
  251. });
  252. }
  253. onClickLeft();
  254. });
  255. };
  256. let showPlace = ref(false);
  257. let religiousType = ref('');
  258. return {
  259. inputForm,
  260. religiousType,
  261. // 返回
  262. onClickLeft,
  263. // 地区选择
  264. showArea,
  265. options,
  266. onFinish,
  267. onFinish2,
  268. customFieldName,
  269. isLoading,
  270. getType,
  271. // 文件上传
  272. chooseImg,
  273. deleteRead,
  274. fileList,
  275. submit,
  276. showCurrentArea,
  277. showPlace,
  278. getLocation
  279. };
  280. },
  281. };
  282. </script>
  283. <style scoped>
  284. .van-uploader .van-button {
  285. border: none;
  286. color: #36a7f3;
  287. top: -4px;
  288. }
  289. .rowTextArea::v-deep .van-field__value {
  290. width: 98%;
  291. border: 2px solid #ccc;
  292. border-radius: 10px;
  293. padding-left: 10px;
  294. }
  295. .rowTextArea::v-deep .van-cell {
  296. display: flow-root;
  297. }
  298. .van-radio {
  299. margin-right: 10px;
  300. }
  301. </style>