placeTabletInfo.vue 13 KB

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