addSanfangHetong.vue 7.1 KB

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