sanfangHetong.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view class="admin-sfht-list">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">三方合同</text>
  6. <uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20" @click="toggle('top')"></uni-icons>
  7. </view>
  8. <view class="phone-head-tab-box">
  9. <!-- 技能块展示 -->
  10. <view v-for="item in listStatus" @click="handleSelectStatus(item)" :key="item.status"
  11. class="tab-item-box" :class="{ active: data.status === item.status }">
  12. {{ item.statusText }}
  13. </view>
  14. </view>
  15. <view class="list-new-btn-box">
  16. <button type="default" class="phone-green-btn" @click="handleAdd">新增合同</button>
  17. </view>
  18. <view>
  19. <search-dialog ref="searchDialogRef" :shenfen="shenfen" @search-btn="dialogSearchBtn"
  20. @reset-search="dialogSearchReset"></search-dialog>
  21. </view>
  22. <!-- 无限滚动容器 -->
  23. <view>
  24. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  25. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  26. @refresherrefresh="onRefresh">
  27. <uni-list class="sfht-scroll-view">
  28. <uni-list-item v-for="item in data.list" class="sfht-list-item-box">
  29. <template v-slot:body>
  30. <view class="sfht-card-box">
  31. <view class="card-head-row">
  32. <view @click="handleDelete(item)" class="del-btn-box">
  33. <icon class="del-btn"></icon>
  34. </view>
  35. <button type="default" class="phone-green-btn ht-head-btn" v-if="item.status == 0" @click="tuisong(item)">推送</button>
  36. <button type="default" class="phone-green-btn ht-head-btn"
  37. @click.stop="handlePreview(item)">预览</button>
  38. <button type="default" class="phone-white-btn ht-head-btn"
  39. @click.stop="handleEditor(item)" v-if="item.status<2">编辑</button>
  40. <button type="default" v-if="item.status==1" class="phone-white-btn ht-head-btn"
  41. @click.stop="handleShengxiao(item)">生效</button>
  42. </view>
  43. <view class="card-body-row">
  44. <view class="body-row">
  45. <view class="title-text">
  46. <icon class="user-icon"></icon>家政人员名称
  47. </view>
  48. <view class="value-text">{{item.realName}}</view>
  49. </view>
  50. <view class="body-row">
  51. <view class="title-text">
  52. <icon class="idcard-icon"></icon>客户名称
  53. </view>
  54. <view class="value-text">{{item.khName}}</view>
  55. </view>
  56. </view>
  57. <view class="card-body-row">
  58. <view class="body-row">
  59. <view class="title-text">
  60. <icon class="date-icon"></icon>合同开始时间
  61. </view>
  62. <view class="value-text">{{item.startDate}}</view>
  63. </view>
  64. <view class="body-row">
  65. <view class="title-text">
  66. <icon class="date-icon"></icon>合同结束时间
  67. </view>
  68. <view class="value-text">{{item.endDate}}</view>
  69. </view>
  70. <view class="body-row">
  71. <view class="title-text">
  72. <icon class="htzt-icon"></icon>合同状态
  73. </view>
  74. <view class="status-0" v-if="item.status== 0">待签字</view>
  75. <view class="status-1" v-if="item.status== 1">待审核</view>
  76. <view class="status-2" v-if="item.status== 2">有效</view>
  77. <view class="status-3" v-if="item.status== 3">失效</view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. </uni-list-item>
  83. <uni-load-more :status="data.state" @click="getMore(0)"
  84. :contentText="data.contentText"></uni-load-more>
  85. </uni-list>
  86. </scroll-view>
  87. </view>
  88. <!-- 删除子账号 -->
  89. <common-dialog ref="commonDialogRef" title="删除确认" content="你确定要执行这个操作吗"
  90. @confirm-btn="handleDeleteConfirm"></common-dialog>
  91. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  92. </view>
  93. </template>
  94. <script setup>
  95. import {
  96. ref,
  97. reactive,
  98. nextTick
  99. } from "vue";
  100. import {
  101. onShow,
  102. onLoad
  103. } from "@dcloudio/uni-app";
  104. import * as httpApi from "@/api/sanfang.js"
  105. import searchDialog from "./components/search.vue";
  106. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  107. import commonDialog from '@/components/dialog/commonDialog.vue';
  108. import {toast} from "@/utils/common";
  109. import config from "../../../config.js"
  110. import {
  111. getSanfangDelete
  112. } from "../../../api/sanfang";
  113. const searchDialogRef = ref(null);
  114. const commonDialogRef = ref(null)
  115. const data = reactive({
  116. status: -1,
  117. statusText: '待签字',
  118. state: 'more',
  119. list: [], // 考试列表
  120. loading: false,
  121. jzRealName: '',
  122. khRealName: '',
  123. page: 0,
  124. size: 10,
  125. })
  126. const active = ref(null);
  127. const listStatus = ref([{
  128. statusText: '全部',
  129. status: -1,
  130. },{
  131. statusText: '待签字',
  132. status: 0,
  133. },{
  134. statusText: '待审核',
  135. status: 1,
  136. },{
  137. statusText: '有效',
  138. status: 2,
  139. },
  140. {
  141. statusText: '失效',
  142. status: 3,
  143. }
  144. ])
  145. const shenfen = ref(null);
  146. function toggle() {
  147. searchDialogRef.value.handleShow();
  148. }
  149. function handleShengxiao(da) {
  150. httpApi.getSanfangShengxiao({id:da.id}).then(res => {
  151. if (res.data) {
  152. uni.showToast({
  153. title: '合同已生效'
  154. })
  155. onRefresh();
  156. }
  157. })
  158. }
  159. function tuisong(data){
  160. // 分享到小程序 单独写不参与组件
  161. uni.share({
  162. provider: 'weixin',
  163. scene: "WXSceneSession",
  164. type: 5,
  165. imageUrl: 'https://www.chengxiangjiaoyu.com/pic/hetong.jpg',
  166. title: '合同',
  167. miniProgram: {
  168. id: 'gh_fa5889151e7d',
  169. path: 'pages/Login/clientIndex?from=appcx&id='+data.id,
  170. type: config.hetongType, //暂时用体验版 0-正式版; 1-测试版; 2-体验版。 默认值为0。
  171. webUrl: 'http://uniapp.dcloud.io'
  172. },
  173. success: ret => {
  174. console.log(JSON.stringify(ret));
  175. },
  176. fail:(error) =>{
  177. console.log('error',error);
  178. // uni.showToast({
  179. // title: error.errMsg
  180. // })
  181. toast(error.errMsg)
  182. }
  183. });
  184. }
  185. function goUpPage() {
  186. // uni.redirectTo({
  187. // url: '/pages/admin/ShouYe/shouye'
  188. // })
  189. uni.navigateBack()
  190. }
  191. function handleSelectStatus(item) {
  192. data.status = item.status;
  193. data.statusText = item.statusText;
  194. onRefresh();
  195. }
  196. function handleAdd() {
  197. uni.navigateTo({
  198. url: '/pages/admin/Hetong/addSanfangHetong'
  199. })
  200. }
  201. function handleDelete(item) {
  202. active.value = item;
  203. commonDialogRef.value.handleShow();
  204. }
  205. function handleDeleteConfirm() {
  206. httpApi.getSanfangDelete({
  207. id: active.value.id
  208. }).then(res => {
  209. if (res.code == 0) {
  210. uni.showToast({
  211. title: '成功'
  212. })
  213. onRefresh();
  214. } else {
  215. uni.showToast({
  216. title: '失败'
  217. })
  218. }
  219. })
  220. }
  221. function handleEditor(item) {
  222. uni.navigateTo({
  223. url: `/pages/admin/Hetong/addSanfangHetong?flag=editor&id=${item.id}`
  224. })
  225. }
  226. function handlePreview(item) {
  227. uni.navigateTo({
  228. url: `/pages/admin/Hetong/previewHetong?id=${item.id}`
  229. })
  230. }
  231. function dialogSearchBtn(opt, searchInput) {
  232. if (opt == 2) {
  233. data.khRealName = searchInput
  234. data.jzRealName = '';
  235. } else {
  236. data.khRealName = '';
  237. data.jzRealName = searchInput
  238. }
  239. onRefresh()
  240. }
  241. function dialogSearchReset() {
  242. data.jzRealName = '';
  243. data.khRealName = '';
  244. }
  245. function onScrolltolower() {
  246. getMore()
  247. }
  248. function onRefresh() {
  249. if (data.loading) return;
  250. data.state = '';
  251. data.page = 0;
  252. data.list = [];
  253. data.loading = true;
  254. refreshData();
  255. }
  256. function refreshData() {
  257. const opt = {
  258. jzRealName: data.jzRealName,
  259. khRealName: data.khRealName,
  260. page: data.page,
  261. size: data.size,
  262. status: data.status
  263. }
  264. data.list = [];
  265. // 数学
  266. data.state = 'loading';
  267. data.page++;
  268. opt.page = data.page;
  269. httpApi.getSanfangList(opt).then(res => {
  270. data.list = data.list.concat(res.data.data);
  271. data.loading = false;
  272. if (res.data.total > data.list.length) {
  273. data.state = 'more';
  274. } else {
  275. data.state = 'no-more';
  276. }
  277. }).catch(err => {
  278. data.state = 'more';
  279. }).finally(() => {
  280. data.loading = false;
  281. })
  282. }
  283. function getMore() {
  284. const opt = {
  285. jzRealName: data.jzRealName,
  286. khRealName: data.khRealName,
  287. page: data.page,
  288. size: data.size,
  289. status: data.status
  290. }
  291. if (data.state == 'no-more') return;
  292. data.state = 'loading';
  293. data.page++;
  294. opt.page = data.page;
  295. httpApi.getSanfangList(opt).then(res => {
  296. data.list = data.list.concat(res.data.data);
  297. data.loading = false;
  298. if (res.data.total > data.list.length) {
  299. data.state = 'more';
  300. } else {
  301. data.state = 'no-more';
  302. }
  303. }).catch(err => {
  304. data.state = 'more';
  305. }).finally(() => {
  306. data.loading = false;
  307. })
  308. }
  309. onLoad((options) => {
  310. const {
  311. from,
  312. jzName,
  313. khName
  314. } = options;
  315. if (jzName) {
  316. data.jzRealName = jzName;
  317. shenfen.value = 'jz'
  318. nextTick(() => {
  319. searchDialogRef.value.handleSetValue(jzName)
  320. })
  321. }
  322. if (khName) {
  323. data.khRealName = khName
  324. shenfen.value = 'kh'
  325. nextTick(() => {
  326. searchDialogRef.value.handleSetValue(khName)
  327. })
  328. }
  329. })
  330. onShow(() => {
  331. data.page = 0;
  332. data.list = [];
  333. data.state = '';
  334. getMore()
  335. })
  336. </script>
  337. <style>
  338. </style>