소스 검색

客户页面

wangxy 23 시간 전
부모
커밋
541376dd54
4개의 변경된 파일259개의 추가작업 그리고 47개의 파일을 삭제
  1. 46 0
      api/sanfang.js
  2. 46 14
      pages/admin/Hetong/addSanfangHetong.vue
  3. 93 0
      pages/admin/Hetong/previewHetong.vue
  4. 74 33
      pages/admin/Hetong/sanfangHetong.vue

+ 46 - 0
api/sanfang.js

@@ -66,7 +66,53 @@ export function getSanfangAdd(data = {}) {
 
 
 
+export function getSanfangInfo(data = {}) {
+  return request({
+    url: '/app/guanliyuan/sanfang/info',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
+
+export function getSanfangUpdate(data = {}) {
+  return request({
+    url: '/app/guanliyuan/sanfang/update',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
 
+export function getSanfangPreview(data = {}) {
+  return request({
+    url: '/app/guanliyuan/sanfang/preview',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
+
+export function getSanfangDelete(data = {}) {
+  return request({
+    url: '/app/guanliyuan/sanfang/delete',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
 
 
 

+ 46 - 14
pages/admin/Hetong/addSanfangHetong.vue

@@ -39,7 +39,8 @@
 		</view>
 
 		<view class="sfht-info-btn-box">
-			<button type="default" class="phone-green-btn" @click="handleAdd">创建合同</button>
+      <button type="default" class="phone-green-btn" @click="handleAdd" v-if="data.type == 'addHetong'">创建合同</button>
+      <button type="default" class="phone-green-btn" @click="handleUpdate" v-if="data.type == 'editorHetong'">更新合同</button>
 		</view>
 	</view>
 </template>
@@ -65,6 +66,7 @@
 	import {
 		useHetong
 	} from "./useHetong.js"
+  import {getSanfangInfo} from "../../../api/sanfang";
 
 	const {
 		provideHetong
@@ -76,7 +78,7 @@
 		mobanList: [],
 		mobanIndex: null,
 		hetong: {
-			htId: 1, // 合同模板id
+			htId: null, // 合同模板id
 			baochou: '', // 基本月报酬
 			qita: '', // 其他服务
 			bingren: '', // 病人病情
@@ -102,7 +104,6 @@
 			lrnianling: '', // 照顾老人年龄: 60,70,80
 			lxName: '', // 其他服务类型名称
 			mianji: '', // 住房面积
-			qita: '', // 基本月报酬
 			qzHaizi: '', // 全职照顾孩子人数
 			qzHzNianliang: '', // 全职照顾孩子年龄
 			realName: '', // 家政姓名
@@ -115,7 +116,9 @@
 			shentizhuangkuang: 1, // 身体状态,1 能自理 ,2半自理, 3不能自理
 			beizhu: '', // 备注
 			qianming: '',
+      id: null
 		},
+    type: null
 	})
 	
 	const commonDialogRef = ref(null)
@@ -138,7 +141,7 @@
 	}
 
 	function getMoban() {
-		httpApi.getMobanList().then(res => {
+		return httpApi.getMobanList().then(res => {
 			data.mobanList = res.data;
 			// 初始化默认选中
 			data.mobanIndex = 0;
@@ -154,9 +157,9 @@
 	}
 
 	function handleAdd() {
-		const opt = Object({}, {...data.hetong},{htId:data.mobanList[data.mobanIndex].id })
+		const opt = Object.assign({}, {...data.hetong,htId:data.mobanList[data.mobanIndex].id })
 		
-		httpApi.getSanfangAdd(data.hetong).then(res => {
+		httpApi.getSanfangAdd(opt).then(res => {
 			if (res.data) {
 				uni.showToast({
 					title: "创建成功",
@@ -167,6 +170,20 @@
 			}
 		})
 	}
+
+  function handleUpdate() {
+    const opt = Object.assign({}, {...data.hetong,htId:data.mobanList[data.mobanIndex].id })
+    httpApi.getSanfangUpdate(opt).then(res => {
+      if (res.data) {
+        uni.showToast({
+          title: "创建成功",
+          success() {
+            uni.navigateBack()
+          }
+        })
+      }
+    })
+  }
 	
 	function handleConfirm() {
 		uni.redirectTo({
@@ -174,14 +191,29 @@
 		})
 	}
 
-	onLoad(() => {
-		httpApi.getSanfangCheck().then(res => {
-			if (res.data) {
-				getMoban();
-			} else {
-				commonDialogRef.value.handleShow()
-			}
-		})
+	onLoad((option) => {
+
+    const { flag, id } = option;
+
+    if (flag) {
+      data.type = 'editorHetong'
+      getMoban().then(() => {
+        httpApi.getSanfangInfo({id}).then(res => {
+          Object.assign(data.hetong,res.data)
+        })
+      })
+    } else {
+      data.type = 'addHetong'
+      httpApi.getSanfangCheck().then(res => {
+        if (res.data) {
+          getMoban();
+        } else {
+          commonDialogRef.value.handleShow()
+        }
+      })
+    }
+
+
 	})
 </script>
 

+ 93 - 0
pages/admin/Hetong/previewHetong.vue

@@ -0,0 +1,93 @@
+<template>
+  <view class="phone-hetong-page">
+    <view class="phone-navBar-box">
+      <view @click="goUpPage" class="nav-bar-icon"></view>
+      <text class="nav-bar-title">合同</text>
+      <view></view>
+    </view>
+    <template v-if="tId">
+      <view class="pdf-box">
+        <img v-for="item in imgList" mode="aspectFit" :src="`data:image/png;base64,${item}`"
+             @click="previewBase64Image(`data:image/png;base64,${item}`)" class="pdf-img" />
+      </view>
+      <!-- 加载提示 -->
+      <view class="pdf-tip-box" v-if="isLoading">
+        <view class="tip-img-box">
+          <view class="tip-text">加载中...</view>
+        </view>
+      </view>
+    </template>
+  </view>
+</template>
+
+<script setup>
+import {
+  ref
+} from "vue";
+import * as httpApi from "@/api/hetong.js"
+import {
+  onLoad
+} from "@dcloudio/uni-app"
+import {getSanfangPreview} from "../../../api/sanfang";
+
+const tId = ref(null)
+
+const info = ref({})
+const show = ref(false)
+const imgList = ref([])
+const isLoading = ref(true)
+const timer1 = ref(null)
+
+onLoad((options) => {
+  tId.value = options.id;
+  init();
+})
+
+function init() {
+  getSanfangPreview({
+    id: tId.value
+  }).then(res => {
+    info.value = res.data;
+    imgList.value = res.data.base64List;
+  }).finally(() => {
+    isLoading.value = false;
+  })
+}
+
+async function previewBase64Image(base64Data) {
+  try {
+    // 关键步骤:将 Base64 字符串转换为本地临时路径
+    // 此处以使用 image-tools 的 base64ToPath 为例
+    const localPath = await base64ToPath(base64Data);
+    // 调用 UniApp 的图片预览 API
+    uni.previewImage({
+      urls: [localPath], // 注意:urls 参数需要是数组,即使只预览一张图
+      current: 0, // 当前显示图片在 urls 数组中的索引
+    });
+  } catch (error) {
+    // 如果出现错误(如转换失败),隐藏加载提示并告知用户
+    console.error('预览失败:', error);
+    uni.showToast({
+      title: '预览失败',
+      icon: 'none'
+    });
+  }
+}
+
+function goUpPage() {
+  uni.navigateBack()
+  clearTimeout(timer1.value);
+  timer1.value = null;
+}
+
+function handleGoLishi() {
+  uni.redirectTo({
+    url: '/pages/admin/Hetong/HetongList'
+  })
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 74 - 33
pages/admin/Hetong/sanfangHetong.vue

@@ -40,38 +40,40 @@
 				<uni-list class="admin-list-box">
 					<uni-list-item v-for="item in data.list" class="jz-list-item-box">
 						<template v-slot:body>
-							<view class="head-top">
-								<button type="default">预览</button>
-								<button type="default">推送</button>
-								<button type="default">删除</button>
-							</view>
-							<view>
-								<view>
-									<view>家政人员名称</view>
-									<view>{{item.jzRealName}}</view>
-								</view>
-								<view>
-									<view>客户名称</view>
-									<view>{{item.khRealName}}</view>
-								</view>
-							</view>
-							<view>
-								<view>
-									<view>合同开始时间</view>
-									<view>{{item.startDate}}</view>
-								</view>
-								<view>
-									<view>合同结束时间</view>
-									<view>{{item.endDate}}</view>
-								</view>
-								<view>
-									<view>合同状态</view>
-									<view v-if="item.status== 0">待签字</view>
-									<view v-if="item.status== 1">待审核</view>
-									<view v-if="item.status== 2">有效</view>
-									<view v-if="item.status== 3">失效</view>
-								</view>
-							</view>
+              <view  @click="handleEditor(item)">
+                <view class="head-top">
+                  <button type="default" @click.stop="handlePreview(item)">预览</button>
+                  <button type="default">推送</button>
+                  <button type="default" @click="handleDelete(item)">删除</button>
+                </view>
+                <view>
+                  <view>
+                    <view>家政人员名称</view>
+                    <view>{{item.jzRealName}}</view>
+                  </view>
+                  <view>
+                    <view>客户名称</view>
+                    <view>{{item.khRealName}}</view>
+                  </view>
+                </view>
+                <view>
+                  <view>
+                    <view>合同开始时间</view>
+                    <view>{{item.startDate}}</view>
+                  </view>
+                  <view>
+                    <view>合同结束时间</view>
+                    <view>{{item.endDate}}</view>
+                  </view>
+                  <view>
+                    <view>合同状态</view>
+                    <view v-if="item.status== 0">待签字</view>
+                    <view v-if="item.status== 1">待审核</view>
+                    <view v-if="item.status== 2">有效</view>
+                    <view v-if="item.status== 3">失效</view>
+                  </view>
+                </view>
+              </view>
 						</template>
 					</uni-list-item>
 					<uni-load-more :status="data.state" @click="getMore(0)"
@@ -80,7 +82,9 @@
 			</scroll-view>
 		</view>
 
-
+    <!-- 删除子账号 -->
+    <common-dialog ref="commonDialogRef" title="删除确认" content="你确定要执行这个操作吗"
+                   @confirm-btn="handleDeleteConfirm"></common-dialog>
 
 		<customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
 
@@ -100,8 +104,11 @@
 	import * as httpApi from "@/api/sanfang.js"
 	import searchDialog from "./components/search.vue";
 	import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
+  import commonDialog from '@/components/dialog/commonDialog.vue';
+  import {getSanfangDelete} from "../../../api/sanfang";
 
 	const searchDialogRef = ref(null);
+  const commonDialogRef = ref(null)
 	const data = reactive({
 		status: 0,
 		statusText: '待签字',
@@ -115,6 +122,8 @@
 	})
 	const isOpen = ref(false)
 
+  const active = ref(null);
+
 	const listStatus = ref([{
 			statusText: '有效',
 			status: 2,
@@ -160,6 +169,38 @@
 		})
 	}
 
+  function handleDelete(item) {
+    active.value = item;
+    commonDialogRef.value.handleShow();
+  }
+
+  function handleDeleteConfirm() {
+    httpApi.getSanfangDelete({id: active.value.id}).then(res => {
+      if (res.code == 0) {
+        uni.showToast({
+          title: '成功'
+        })
+        onRefresh();
+      } else {
+        uni.showToast({
+          title: '失败'
+        })
+      }
+    })
+  }
+
+  function handleEditor(item) {
+    uni.navigateTo({
+      url: `/pages/admin/Hetong/addSanfangHetong?flag=editor&id=${item.id}`
+    })
+  }
+
+  function handlePreview(item) {
+    uni.navigateTo({
+      url: `/pages/admin/Hetong/previewHetong?id=${item.id}`
+    })
+  }
+
 	function dialogSearchBtn(opt, searchInput) {
 		if (opt == 2) {
 			data.khRealName = searchInput