placeTabletAdd.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <van-nav-bar
  3. fixed
  4. title="牌位信息录入"
  5. left-arrow
  6. @click-left="onClickLeft"
  7. :style="{ 'background-color': selectColor }"
  8. />
  9. <div class="main">
  10. <van-cell-group>
  11. <van-field
  12. v-model="inputForm.brandName"
  13. center
  14. required
  15. label="牌位名称:"
  16. placeholder="请填写牌位名称"
  17. input-align="right"
  18. />
  19. </van-cell-group>
  20. <van-cell-group>
  21. <van-field
  22. v-model="locationName"
  23. readonly
  24. required
  25. label="所属场所:"
  26. placeholder="请选择所属场所"
  27. input-align="right"
  28. right-icon="arrow-down"
  29. @click="hs_site = true"
  30. >
  31. </van-field>
  32. <van-dialog v-model:show="hs_site" title="所属场所" show-cancel-button>
  33. <div class="dialog">
  34. <van-list
  35. v-model:loading="loading"
  36. :finished="finished"
  37. finished-text="没有更多了"
  38. @load="onLoad"
  39. >
  40. <van-radio-group v-model="checked">
  41. <van-cell-group inset>
  42. <van-cell
  43. v-for="item in sitelist"
  44. :key="item"
  45. :title="item.name"
  46. clickable
  47. @click="getsite(item)"
  48. >
  49. <template #right-icon>
  50. <van-radio :name="item.id" />
  51. </template>
  52. </van-cell>
  53. </van-cell-group>
  54. </van-radio-group>
  55. </van-list>
  56. </div>
  57. </van-dialog>
  58. </van-cell-group>
  59. <van-cell-group>
  60. <van-field
  61. v-model="inputForm.siteContact"
  62. center
  63. disabled
  64. label="场所联系人:"
  65. placeholder="请填写场所联系人"
  66. input-align="right"
  67. />
  68. </van-cell-group>
  69. <van-cell-group>
  70. <van-field
  71. v-model="inputForm.contactInformation"
  72. center
  73. disabled
  74. label="联系方式:"
  75. placeholder="请填写联系方式"
  76. input-align="right"
  77. />
  78. </van-cell-group>
  79. <van-cell-group>
  80. <van-field
  81. v-model="inputForm.memorialTabletHolder"
  82. center
  83. label="供奉牌位人:"
  84. placeholder="请填写供奉牌位人"
  85. input-align="right"
  86. />
  87. </van-cell-group>
  88. <van-cell-group>
  89. <van-field
  90. v-model="inputForm.memorialTabletHolderPhone"
  91. center
  92. label-width="8em"
  93. label="供奉牌位人电话:"
  94. placeholder="请填写供奉牌位人电话"
  95. input-align="right"
  96. />
  97. </van-cell-group>
  98. <van-cell-group>
  99. <van-field
  100. v-model="inputForm.udCard"
  101. center
  102. required
  103. label="身份证号:"
  104. placeholder="请填写身份证号"
  105. input-align="right"
  106. />
  107. </van-cell-group>
  108. <van-cell-group>
  109. <van-field
  110. v-model="inputForm.nativePlace"
  111. readonly
  112. label="籍贯:"
  113. placeholder="请选择籍贯地区"
  114. input-align="right"
  115. right-icon="arrow-down"
  116. @click="hs_nativePlace = true"
  117. />
  118. <van-popup v-model:show="hs_nativePlace" round position="bottom">
  119. <van-picker
  120. title="籍贯"
  121. :columns="nativePlace"
  122. :columns-field-names="customFieldName"
  123. @cancel="hs_nativePlace = false"
  124. @confirm="getnativePlace"
  125. />
  126. </van-popup>
  127. </van-cell-group>
  128. <van-cell-group>
  129. <van-field
  130. v-model="inputForm.currentResidence"
  131. center
  132. readonly
  133. label="现居地:"
  134. placeholder="请填写现居地"
  135. input-align="right"
  136. right-icon="arrow-down"
  137. @click="showPlace1 = true"
  138. />
  139. <van-popup v-model:show="showPlace1" round position="bottom">
  140. <van-picker
  141. title="现居地选择"
  142. :columns="options"
  143. :columns-field-names="customFieldName"
  144. @cancel="showPlace1 = false"
  145. @confirm="getPlace1"
  146. />
  147. </van-popup>
  148. </van-cell-group>
  149. <van-cell-group>
  150. <van-field
  151. v-model="inputForm.currentResidenceDel"
  152. center
  153. label="现居地详情:"
  154. placeholder="请填写现居地详情"
  155. input-align="right"
  156. />
  157. </van-cell-group>
  158. <van-cell-group>
  159. <van-field
  160. v-model="inputForm.relationship"
  161. center
  162. label-width="8em"
  163. label="与供奉牌位关系:"
  164. placeholder="请填写与供奉牌位关系"
  165. input-align="right"
  166. />
  167. </van-cell-group>
  168. <van-cell-group>
  169. <van-field
  170. v-model="inputForm.sacrificeExpenses"
  171. center
  172. label-width="10em"
  173. label="供奉费用(元/年):"
  174. placeholder="请填写供奉费用"
  175. input-align="right"
  176. />
  177. </van-cell-group>
  178. <van-cell-group>
  179. <van-field
  180. v-model="inputForm.position"
  181. center
  182. label="牌位位置:"
  183. placeholder="请填写牌位位置"
  184. input-align="right"
  185. />
  186. </van-cell-group>
  187. <van-cell-group>
  188. <van-field
  189. v-model="inputForm.information"
  190. rows="2"
  191. autosize
  192. label-width="8em"
  193. label="被供奉者信息:"
  194. type="textarea"
  195. maxlength="50"
  196. placeholder="请填写被供奉者信息"
  197. show-word-limit
  198. input-align="right"
  199. />
  200. </van-cell-group>
  201. <van-cell-group>
  202. <van-field name="uploader" label-align="top" label="工作照片:">
  203. <template #input>
  204. <van-uploader
  205. v-model="fileList"
  206. :after-read="afterRead1"
  207. :max-count="6"
  208. capture="camera"
  209. accept=""
  210. :before-delete="fjdelete"
  211. >
  212. </van-uploader>
  213. </template>
  214. </van-field>
  215. </van-cell-group>
  216. <div class="subbtn">
  217. <van-button type="primary" @click="submit">提交</van-button>
  218. <van-button @click="onClickLeft" type="default" hairline>取消</van-button>
  219. </div>
  220. </div>
  221. </template>
  222. <script>
  223. import { onMounted, ref } from "vue";
  224. import TabletServer from "@/api/tabletManage/TabletServer";
  225. import placePerson from "@/api/placePerson/placePerson";
  226. import PlaceRegister from "@/api/placeRegister/placeRegister";
  227. import tools from "@/api/sys/tools";
  228. export default {
  229. setup() {
  230. const onClickLeft = () => {
  231. history.back();
  232. };
  233. const inputForm = ref({
  234. id: "",
  235. brandName: "",
  236. siteName: {
  237. id: "",
  238. },
  239. siteContact: "",
  240. contactInformation: "",
  241. memorialTabletHolder: "",
  242. memorialTabletHolderPhone: "",
  243. udCard: "",
  244. nativePlace: "",
  245. currentResidence: "",
  246. currentResidenceDel: "",
  247. relationship: "",
  248. sacrificeExpenses: "",
  249. position: "",
  250. state: "0",
  251. keepOnRecord: "0",
  252. pic: "",
  253. information: "",
  254. });
  255. onMounted(() => {
  256. //籍贯接口
  257. new placePerson().nativePlace().then((res) => {
  258. nativePlace.value.push(...res);
  259. options.value.push(...res);
  260. });
  261. });
  262. // 所属场所
  263. const locationName = ref("");
  264. const checked = ref("");
  265. const sitelist = ref([]);
  266. let hs_site = ref(false);
  267. const getsite = (val) => {
  268. locationName.value = val.name;
  269. const json = Object.assign(inputForm.value, {
  270. siteName: { id: val.id },
  271. siteContact: val.contact,
  272. contactInformation: val.contactNumber,
  273. });
  274. inputForm.value = json;
  275. checked.value = val.id;
  276. };
  277. const loading = ref(false);
  278. const finished = ref(false);
  279. const refreshing = ref(false);
  280. let index = 0;
  281. const onLoad = () => {
  282. loading.value = true;
  283. finished.value = false;
  284. // 异步更新数据
  285. new PlaceRegister()
  286. .religiousList({
  287. current: index + 1,
  288. size: 10,
  289. })
  290. .then(({ records, pages }) => {
  291. sitelist.value = sitelist.value.concat(records);
  292. // 加载状态结束
  293. loading.value = false;
  294. if (index + 1 >= pages) {
  295. finished.value = true;
  296. }
  297. index++;
  298. });
  299. };
  300. //籍贯
  301. const customFieldName = {
  302. text: "name",
  303. value: "id",
  304. };
  305. const options = ref([]);
  306. const nativePlace = ref([]);
  307. let hs_nativePlace = ref(false);
  308. const getnativePlace = ({ selectedOptions }) => {
  309. hs_nativePlace.value = false;
  310. let str = "";
  311. selectedOptions.forEach((item) => {
  312. if (inputForm.nativePlace) {
  313. str = inputForm.nativePlace;
  314. }
  315. str += item.name + "/";
  316. });
  317. inputForm.nativePlace = str;
  318. const json = Object.assign(inputForm.value, { nativePlace: str });
  319. inputForm.value = json;
  320. };
  321. //现居地
  322. let placeAddress = ref("");
  323. let showPlace1 = ref(false);
  324. const getPlace1 = ({ selectedOptions }) => {
  325. showPlace1.value = false;
  326. let str1 = "";
  327. selectedOptions.forEach((item) => {
  328. if (inputForm.currentResidence) {
  329. str1 = inputForm.currentResidence;
  330. }
  331. str1 += item.name + "/";
  332. });
  333. const json = Object.assign(inputForm.value, {
  334. currentResidence: str1,
  335. });
  336. inputForm.value = json;
  337. };
  338. //图片上传
  339. let fileList = ref([]);
  340. let fileImg = ref([]);
  341. let workpic = ref("");
  342. const afterRead1 = (file) => {
  343. new tools()
  344. .uploadFile(file, `sys/file/webupload/upload`)
  345. .then(({ data }) => {
  346. data.name = decodeURIComponent(
  347. data.url.substring(data.url.lastIndexOf("/") + 1)
  348. );
  349. workpic.value += "" + data.url;
  350. const json = Object.assign(inputForm.value, {
  351. pic: workpic.value,
  352. });
  353. inputForm.value = json;
  354. fileImg.value.push(data);
  355. });
  356. };
  357. const fjdelete = (file) => {
  358. //删除文件操作
  359. for (let index = 0; index < fileList.value.length; index++) {
  360. if (file.file == fileList.value[index].file) {
  361. let delurl = fileImg.value[index].url;
  362. new tools().uploadFiledelete("", delurl).then(({ data }) => {});
  363. fileImg.value.splice(index, 1);
  364. fileList.value.splice(index, 1);
  365. }
  366. }
  367. };
  368. //数据提交
  369. const submit = () => {
  370. new TabletServer().save(inputForm.value).then((res) => {
  371. console.log(res);
  372. if (res.status == 200) {
  373. xm.showToast({
  374. message: "人员添加成功",
  375. });
  376. router.push({
  377. path: "/placeTablet",
  378. });
  379. }else{
  380. xm.showToast({
  381. message: "人员添加失败",
  382. });
  383. console.log(res);
  384. }
  385. });
  386. };
  387. return {
  388. inputForm,
  389. onClickLeft,
  390. //所属场所
  391. locationName,
  392. checked,
  393. hs_site,
  394. getsite,
  395. sitelist,
  396. loading,
  397. finished,
  398. onLoad,
  399. refreshing,
  400. //籍贯
  401. nativePlace,
  402. hs_nativePlace,
  403. getnativePlace,
  404. customFieldName,
  405. //现居地
  406. options,
  407. placeAddress,
  408. showPlace1,
  409. getPlace1,
  410. //图片上传
  411. fileList,
  412. afterRead1,
  413. //图片删除
  414. fjdelete,
  415. submit
  416. };
  417. },
  418. };
  419. </script>
  420. <style>
  421. .dialog {
  422. width: 100%;
  423. height: 400px;
  424. overflow: auto;
  425. }
  426. .subbtn {
  427. margin: 20px;
  428. text-align: center;
  429. }
  430. .subbtn .van-button {
  431. width: 40%;
  432. margin: 5px;
  433. }
  434. </style>