addSanfangHetong.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="sfht-info-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">新增三方合同</text>
  6. </view>
  7. <!-- form -->
  8. <view class="sfht-form-box">
  9. <!-- 合同模板 -->
  10. <view class="form-label-select form-radius-box">
  11. <view class="phone-form-label"><text class="form-label-require"></text>合同模板
  12. <i @click="handlePreviewPdf">预览</i></view>
  13. <picker :range="data.mobanList" mode='selector' :value="data.mobanIndex" range-key="name"
  14. @change="onMobanSelect" class="select-picker-box">
  15. <view class="form-radio-select">
  16. <view v-if="data.mobanList[data.mobanIndex]">{{ data.mobanList[data.mobanIndex].name}}</view>
  17. <icon></icon>
  18. </view>
  19. </picker>
  20. </view>
  21. <!-- 客户信息 -->
  22. <kehuCardVue></kehuCardVue>
  23. <!-- 家政人员 -->
  24. <jiazhengCardVue></jiazhengCardVue>
  25. <template v-if="data.mobanIndex == 0">
  26. <!-- 合同信息 -->
  27. <hetongCardVue></hetongCardVue>
  28. <!-- 其他约定 -->
  29. <qiTaYueDingVue></qiTaYueDingVue>
  30. <!-- 家政签名 -->
  31. <qianMingVue></qianMingVue>
  32. </template>
  33. <common-dialog ref="commonDialogRef" title="提示" :showQuxiao="false" content="请完善社会信用代码与服务监督热线"
  34. @confirm-btn="handleConfirm"></common-dialog>
  35. </view>
  36. <view class="sfht-info-btn-box">
  37. <button type="default" class="phone-green-btn" @click="handleAdd"
  38. v-if="data.type == 'addHetong'">创建合同</button>
  39. <button type="default" class="phone-green-btn" @click="handleUpdate"
  40. v-if="data.type == 'editorHetong'">更新合同</button>
  41. </view>
  42. <pdfPreviewVue ref="pdfRef"></pdfPreviewVue>
  43. </view>
  44. </template>
  45. <script setup>
  46. import {
  47. ref,
  48. reactive,
  49. nextTick
  50. } from "vue";
  51. import {
  52. onLoad
  53. } from "@dcloudio/uni-app";
  54. import * as httpApi from "@/api/sanfang.js"
  55. import hetongCardVue from "./components/hetongCard.vue";
  56. import jiazhengCardVue from "./components/jiazhengCard.vue";
  57. import kehuCardVue from "./components/kehuCard.vue";
  58. import qianMingVue from "./components/qianMing.vue";
  59. import qiTaYueDingVue from "./components/qiTaYueDing.vue";
  60. import commonDialog from '@/components/dialog/commonDialog.vue';
  61. import pdfPreviewVue from "./components/pdfPreview.vue";
  62. import {
  63. useHetong
  64. } from "./useHetong.js"
  65. import {
  66. getSanfangInfo
  67. } from "../../../api/sanfang";
  68. const {
  69. provideHetong
  70. } = useHetong()
  71. const emits = defineEmits('select-kehu')
  72. const data = reactive({
  73. mobanList: [],
  74. mobanIndex: null,
  75. hetong: {
  76. htId: null, // 合同模板id
  77. baochou: '', // 基本月报酬
  78. qita: '', // 其他服务
  79. bingren: '', // 病人病情
  80. dizhi: '', // 服务地址
  81. fafangri: '', // 工资发放日
  82. fangshi: 1, // 服务方式,1住家型,2非住家型
  83. fsShijian: '', // 非住家型服务时间
  84. fuwufei: '', // 服务费
  85. fuwufeiRate: '', // 服务费百分比
  86. fzHaizi: '', // 辅助照顾孩子人数
  87. fzHzNianling: '', // 辅助照顾孩子年龄
  88. huli: '', // 产妇护理
  89. jiabingEndDate: '', // 甲丙服务结束时间
  90. jiabingStartDate: '', // 甲丙服务开始时间
  91. jiandurexian: '', // 服务监督热线
  92. jiayiEndDate: '', // 甲乙服务结束时间
  93. jiayiStartDate: '', // 甲乙服务开始时间
  94. khId: '', // 客户ID
  95. khName: '', // 客户姓名
  96. khIdcard: '', // 客户身份证号
  97. laoren: '', // 照顾老人人数
  98. leixing: 1, // 服务类型,1普通家务保姆,2钟点工保姆,3育儿嫂,4其他
  99. lrnianling: '', // 照顾老人年龄: 60,70,80
  100. lxName: '', // 其他服务类型名称
  101. mianji: '', // 住房面积
  102. qzHaizi: '', // 全职照顾孩子人数
  103. qzHzNianliang: '', // 全职照顾孩子年龄
  104. realName: '', // 家政姓名
  105. renkou: '', // 常驻人口数
  106. tianshu: '', // 基本月报酬天数
  107. userId: '', // 家政员ID
  108. xinyongdaima: '', // 统一社会信用代码
  109. xiuxi: '', // 休息天数
  110. khUserName: '', // 客户电话
  111. shentiqingkuang: 0, // 身体状态,1 能自理 ,2半自理, 3不能自理
  112. beizhu: '', // 备注
  113. qianmingBase64: '',
  114. id: null,
  115. jutidizhi: '',
  116. },
  117. type: null,
  118. timer: null
  119. })
  120. const commonDialogRef = ref(null)
  121. // 穿透式传参
  122. provideHetong(data)
  123. const jzRef = ref(null)
  124. const pdfRef = ref(null)
  125. function handleSelct(code) {
  126. if (code == 'kh') {
  127. khRef.value.handleShow();
  128. } else {
  129. jzRef.value.handleShow();
  130. }
  131. }
  132. function handlePreviewPdf() {
  133. const imgList = data.mobanList[data.mobanIndex] && data.mobanList[data.mobanIndex].base64List;
  134. imgList && pdfRef.value.showPDF(imgList)
  135. }
  136. function goUpPage() {
  137. uni.navigateBack()
  138. }
  139. function getMoban() {
  140. return httpApi.getMobanList().then(res => {
  141. data.mobanList = res.data;
  142. // 初始化默认选中
  143. data.mobanIndex = 0;
  144. })
  145. }
  146. function onMobanSelect(da) {
  147. data.mobanIndex = da.detail.value
  148. }
  149. function handleQianming(da) {
  150. data.qianming = da;
  151. }
  152. function handleAdd() {
  153. if (!data.hetong.jiabingStartDate || data.hetong.jiabingEndDate || data.hetong.qianmingBase64) {
  154. toast('请确认合同必填项是否完整')
  155. return;
  156. }
  157. uni.showLoading({
  158. title: '创建中...',
  159. mask: true
  160. });
  161. const opt = Object.assign({}, {
  162. ...data.hetong,
  163. htId: data.mobanList[data.mobanIndex].id
  164. })
  165. httpApi.getSanfangAdd(opt).then(res => {
  166. if (res.data) {
  167. uni.hideLoading()
  168. uni.showToast({
  169. title: "创建成功",
  170. duration: 2000,
  171. success() {
  172. setTimeout(() => {
  173. uni.navigateBack()
  174. }, 2000)
  175. }
  176. })
  177. }
  178. }).catch(() => {
  179. uni.hideLoading()
  180. }).
  181. finally(() => {
  182. clearTimeout(data.timer);
  183. data.timer = null;
  184. })
  185. }
  186. function handleUpdate() {
  187. if (!data.hetong.jiabingStartDate || data.hetong.jiabingEndDate || data.hetong.qianmingBase64) {
  188. toast('请确认合同必填项是否完整')
  189. return;
  190. }
  191. uni.showLoading({
  192. title: '更新中...',
  193. mask: true
  194. });
  195. const opt = Object.assign({}, {
  196. ...data.hetong,
  197. htId: data.mobanList[data.mobanIndex].id
  198. })
  199. httpApi.getSanfangUpdate(opt).then(res => {
  200. if (res.data) {
  201. uni.hideLoading()
  202. uni.showToast({
  203. title: "更新成功",
  204. duration: 2000,
  205. mask: true,
  206. success() {
  207. setTimeout(() => {
  208. uni.navigateBack()
  209. }, 2000)
  210. }
  211. })
  212. }
  213. }).catch(() => {
  214. uni.hideLoading()
  215. })
  216. }
  217. function handleConfirm() {
  218. uni.redirectTo({
  219. url: '/pages/admin/my/jzInfo' // 跳转完善
  220. })
  221. }
  222. onLoad((option) => {
  223. const {
  224. flag,
  225. id
  226. } = option;
  227. if (flag) {
  228. data.type = 'editorHetong'
  229. getMoban().then(() => {
  230. httpApi.getSanfangInfo({
  231. id
  232. }).then(res => {
  233. Object.assign(data.hetong, res.data)
  234. console.log('ccccc', res.data)
  235. })
  236. })
  237. } else {
  238. data.type = 'addHetong'
  239. httpApi.getSanfangCheck().then(res => {
  240. if (res.data) {
  241. getMoban();
  242. } else {
  243. commonDialogRef.value.handleShow()
  244. }
  245. })
  246. }
  247. })
  248. </script>
  249. <style>
  250. </style>