sanfangHetong.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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)">编辑</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. // 合同是否限制编辑:0否,1是
  223. if(item.updFlag===0){
  224. uni.navigateTo({
  225. url: `/pages/admin/Hetong/addSanfangHetong?flag=editor&id=${item.id}`
  226. })
  227. }else{
  228. uni.showToast({
  229. icon: 'none',
  230. title: item.updMsg
  231. })
  232. }
  233. }
  234. function handlePreview(item) {
  235. uni.navigateTo({
  236. url: `/pages/admin/Hetong/previewHetong?id=${item.id}`
  237. })
  238. }
  239. function dialogSearchBtn(opt, searchInput) {
  240. if (opt == 2) {
  241. data.khRealName = searchInput
  242. data.jzRealName = '';
  243. } else {
  244. data.khRealName = '';
  245. data.jzRealName = searchInput
  246. }
  247. onRefresh()
  248. }
  249. function dialogSearchReset() {
  250. data.jzRealName = '';
  251. data.khRealName = '';
  252. }
  253. function onScrolltolower() {
  254. getMore()
  255. }
  256. function onRefresh() {
  257. if (data.loading) return;
  258. data.state = '';
  259. data.page = 0;
  260. data.list = [];
  261. data.loading = true;
  262. refreshData();
  263. }
  264. function refreshData() {
  265. const opt = {
  266. jzRealName: data.jzRealName,
  267. khRealName: data.khRealName,
  268. page: data.page,
  269. size: data.size,
  270. status: data.status
  271. }
  272. data.list = [];
  273. // 数学
  274. data.state = 'loading';
  275. data.page++;
  276. opt.page = data.page;
  277. httpApi.getSanfangList(opt).then(res => {
  278. data.list = data.list.concat(res.data.data);
  279. data.loading = false;
  280. if (res.data.total > data.list.length) {
  281. data.state = 'more';
  282. } else {
  283. data.state = 'no-more';
  284. }
  285. }).catch(err => {
  286. data.state = 'more';
  287. }).finally(() => {
  288. data.loading = false;
  289. })
  290. }
  291. function getMore() {
  292. const opt = {
  293. jzRealName: data.jzRealName,
  294. khRealName: data.khRealName,
  295. page: data.page,
  296. size: data.size,
  297. status: data.status
  298. }
  299. if (data.state == 'no-more') return;
  300. data.state = 'loading';
  301. data.page++;
  302. opt.page = data.page;
  303. httpApi.getSanfangList(opt).then(res => {
  304. data.list = data.list.concat(res.data.data);
  305. data.loading = false;
  306. if (res.data.total > data.list.length) {
  307. data.state = 'more';
  308. } else {
  309. data.state = 'no-more';
  310. }
  311. }).catch(err => {
  312. data.state = 'more';
  313. }).finally(() => {
  314. data.loading = false;
  315. })
  316. }
  317. onLoad((options) => {
  318. const {
  319. from,
  320. jzName,
  321. khName
  322. } = options;
  323. if (jzName) {
  324. data.jzRealName = jzName;
  325. shenfen.value = 'jz'
  326. nextTick(() => {
  327. searchDialogRef.value.handleSetValue(jzName)
  328. })
  329. }
  330. if (khName) {
  331. data.khRealName = khName
  332. shenfen.value = 'kh'
  333. nextTick(() => {
  334. searchDialogRef.value.handleSetValue(khName)
  335. })
  336. }
  337. })
  338. onShow(() => {
  339. data.page = 0;
  340. data.list = [];
  341. data.state = '';
  342. getMore()
  343. })
  344. </script>
  345. <style>
  346. </style>