合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
9.8 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <scroll-view class="container" lower-threshold='50' @scrolltolower ='scrolltolower'>
  3. <view class="header">
  4. <view class="header_info" >
  5. <view class="header_info_icon" @click.native.stop.prevent="toBack" style="display: flex; justify-content: center; align-items: center;">
  6. <uni-icons type="left" size="30" color="#c2d4de" > </uni-icons>
  7. </view>
  8. <text class="header_text" >录入订单</text>
  9. </view>
  10. </view>
  11. <!-- 搜索栏 -->
  12. <view class="search-box">
  13. <uni-icons class=" isshow-header-content-icon" type="search" :size="20"></uni-icons>
  14. <uni-easyinput :inputBorder="false" class=" search-input" v-model="searchKey" placeholder="请输入客户姓名/客户手机号" :focus="firstFocus" @clear = 'clear' />
  15. <button @tap="handleSearch" class="search-btn" hover-class="none">搜索</button>
  16. </view>
  17. <!-- 订单状态筛选 -->
  18. <view class="filter-tabs">
  19. <text
  20. v-for="tab in tabs"
  21. :key="tab"
  22. :class="['tab-item', activeTab === tab ? 'active' : '']"
  23. @tap="changeStatus(tab)"
  24. >
  25. {{ tab }}
  26. </text>
  27. </view>
  28. <!-- 订单列表 -->
  29. <view
  30. v-for="(order, index) in filteredOrders"
  31. :key="index"
  32. class="order-item"
  33. >
  34. <view class="order-header">
  35. <text class="order-no">{{ order.orderNum }}</text>
  36. <text class="copy-btn" @tap="copyorderNum(order.orderNum)">复制</text>
  37. </view>
  38. <view class="order-info">
  39. <text>客户姓名:{{ order.custName }}</text>
  40. <text>联系方式:{{ order.custPhone }}</text>
  41. <text>服务名称:{{ order.productName }}</text>
  42. <text>订单时间:{{ order.createTime }}</text>
  43. <text>销售人员:{{ order.saleName }}</text>
  44. <text>门店名称:{{ order.storeName }}</text>
  45. </view>
  46. <button class="download-btn" @tap="downloadPDF(order.contractUrl)" v-if='order.status == 1 ? true : false'>PDF下载</button>
  47. <image src="/static/image/组 71693.png" v-if='order.status == 1 ? true : false' class="status"></image>
  48. <image src="/static/image/组 71697.png" v-if='order.status == 1 ? false : true' class="status"></image>
  49. </view>
  50. </scroll-view>
  51. </template>
  52. <script>
  53. import {list,isToken,addContract} from '@/api.uts'
  54. export default {
  55. data() {
  56. return {
  57. params:{
  58. pageNo: 1,
  59. pageSize: 10,
  60. status: ''
  61. },
  62. firstFocus:false,
  63. searchKey: '', // 搜索关键词
  64. activeTab: '全部', // 当前激活的标签
  65. tabs: ['全部', '已生效', '已失效'],
  66. orders: [/* 从接口获取的数据 */]
  67. }
  68. },
  69. mounted() {
  70. isToken();
  71. list({pageNo:1,pageSize:10}).then((res)=>{
  72. for (var index = 0; index < res.result.records.length; index++) {
  73. this.orders.push( res.result.records[index])
  74. }
  75. })
  76. },
  77. computed: {
  78. filteredOrders() {
  79. return this.orders.filter((item) => {
  80. // 根据多种类型来搜索
  81. return item.custName.includes(this.searchKey) || item.custPhone.includes(this
  82. .searchKey)
  83. })
  84. }
  85. },
  86. methods: {
  87. // 清楚搜索框信息
  88. clear(){
  89. this.searchKey = '';
  90. },
  91. // 到底部刷新
  92. scrolltolower(){
  93. this.params.pageNo++
  94. uni.showLoading({
  95. title: '刷新中..'
  96. })
  97. list(this.params).then((res)=>{
  98. let orders = res.result.records;
  99. for (var index = 0; index < orders.length; index++) {
  100. this.orders.push(orders[index]);
  101. }
  102. uni.hideLoading();
  103. })
  104. },
  105. changeStatus(status){
  106. uni.showLoading();
  107. this.activeTab = status;
  108. if(status== '已生效'){
  109. this.orders.splice(0)
  110. this.params.status = 1;
  111. this.params.pageNo= 1;
  112. list(this.params).then((res)=>{
  113. let orders = res.result.records;
  114. for (var index = 0; index < orders.length; index++) {
  115. this.orders.push(orders[index]);
  116. }
  117. uni.hideLoading();
  118. })
  119. }else if (status== '已失效'){
  120. this.orders.splice(0);
  121. this.params.status = 2;
  122. this.params.pageNo= 1
  123. list(this.params).then((res)=>{
  124. for (var index = 0; index < res.result.records.length; index++) {
  125. this.orders.push(res.result.records[index]);
  126. }
  127. })
  128. uni.hideLoading();
  129. }else{
  130. this.params.status = '';
  131. this.params.pageNo= 1
  132. list(this.params).then((res)=>{
  133. console.log(res.result)
  134. this.orders.splice(0);
  135. for (var index = 0; index < res.result.records.length; index++) {
  136. this.orders.push(res.result.records[index]);
  137. }
  138. uni.hideLoading();
  139. })
  140. }
  141. },
  142. // 回退
  143. toBack(){
  144. let canNavBack = getCurrentPages()
  145. if( canNavBack && canNavBack.length>1) {
  146. uni.navigateBack()
  147. } else {
  148. history.back();
  149. }
  150. },
  151. IsChinese(value) {
  152. const reg = /^[\u4e00-\u9fa5]+$/gi;
  153. return reg.test(value);
  154. },
  155. WhNumber(value) {
  156. return /^\d+$/.test(value);
  157. },
  158. // 搜索处理
  159. handleSearch() {
  160. // 实际调用接口获取数据
  161. uni.showLoading();
  162. // console.log(this.IsChinese(this.searchKey));
  163. if(this.IsChinese(this.searchKey)){
  164. list({custName:this.searchKey,pageNo:1,pageSize:10}).then((res)=>{
  165. this.activeTab = '全部';
  166. this.orders.splice(0);
  167. let orders = res.result.records;
  168. for (var index = 0; index < orders.length; index++) {
  169. this.orders.push(orders[index]);
  170. }
  171. uni.hideLoading();
  172. })
  173. }else if(this.WhNumber(this.searchKey)){
  174. list({custPhone:this.searchKey,pageNo:1,pageSize:10}).then((res)=>{
  175. this.activeTab = '全部';
  176. this.orders.splice(0);
  177. let orders = res.result.records;
  178. for (var index = 0; index < orders.length; index++) {
  179. this.orders.push(orders[index]);
  180. }
  181. uni.hideLoading();
  182. })
  183. }else if(!this.searchKey){
  184. list({pageNo:1,pageSize:10}).then((res)=>{
  185. this.activeTab = '全部';
  186. this.orders.splice(0);
  187. let orders = res.result.records;
  188. for (var index = 0; index < orders.length; index++) {
  189. this.orders.push(orders[index]);
  190. }
  191. uni.hideLoading();
  192. })
  193. }
  194. },
  195. // 复制订单号
  196. copyorderNum(orderNum) {
  197. uni.setClipboardData({
  198. data: orderNum,
  199. success: () => {
  200. uni.showToast({ title: '复制成功' })
  201. }
  202. })
  203. },
  204. // PDF下载
  205. async downloadPDF(contractUrl) {
  206. uni.showLoading({ title: '下载中...' })
  207. // 1. 调用下载接口
  208. uni.downloadFile({
  209. url: contractUrl,//下载地址接口返回
  210. success: (data) => {
  211. uni.saveFile({
  212. tempFilePath: data.tempFilePath, //临时路径
  213. // filePath:"内部存储/Documents/",
  214. success: (res)=> {
  215. uni.hideLoading();
  216. uni.showToast({
  217. icon: 'none',
  218. mask: true,
  219. title: '文件已下载,打开后请点击右上角保存!', //保存路径
  220. duration: 2000,
  221. });
  222. setTimeout(() => { //打开文档查看
  223. uni.openDocument({
  224. filePath: res.savedFilePath,
  225. showMenu:true,
  226. success: function(res) {
  227. list({pageNo:1,pageSize:10}).then((res)=>{
  228. for (var index = 0; index < res.result.records.length; index++) {
  229. this.orders.push( res.result.records[index])
  230. }
  231. })
  232. }
  233. });
  234. }, 3000)
  235. }
  236. })
  237. },
  238. fail: (err) => {
  239. console.log(err);
  240. uni.showToast({
  241. icon: 'none',
  242. mask: true,
  243. title: '失败请重新下载',
  244. });
  245. },
  246. });
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .search-box {
  253. height: 10%;
  254. display: flex;
  255. flex-direction: row;
  256. margin-bottom: 30rpx;
  257. align-items: center;
  258. .search-input {
  259. flex: 1;
  260. background: #fff;
  261. padding: 20rpx;
  262. border-radius: 8rpx;
  263. }
  264. .search-btn {
  265. width: 20%;
  266. height: 40%;
  267. margin-right: 10%;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. font-size: 1rem;
  272. color: #044f7a;
  273. border: none;
  274. }
  275. .search-btn:after {
  276. border: none;
  277. }
  278. .isshow-header-content-icon{
  279. display: flex;
  280. justify-content: center;
  281. margin-left: 10%;
  282. align-items: center;
  283. }
  284. }
  285. .filter-tabs {
  286. display: flex;
  287. flex-direction: row;
  288. margin-bottom: 30rpx;
  289. position: relative;
  290. .tab-item {
  291. flex: 1;
  292. width: 10%;
  293. text-align: center;
  294. padding: 20rpx;
  295. color: #000000;
  296. border-bottom: 4rpx solid transparent;
  297. &.active {
  298. color: #044f7a;
  299. // border-bottom-color: #044f7a;
  300. }
  301. &.active:after {
  302. content: '';
  303. width: 50%;
  304. height: 1px;
  305. display: block;
  306. margin: 0 auto;
  307. border-bottom: 2px solid #044f7a;
  308. color: #044f7a;
  309. padding: 1px;
  310. }
  311. }
  312. }
  313. .order-item {
  314. margin: 0 auto;
  315. width: 80%;
  316. height: 30%;
  317. box-shadow: -0.1rem 0.1rem #e4e4e4;
  318. border: 1px solid #e1e1e1;
  319. border-radius: 0.5rem;
  320. position: relative;
  321. background: white;
  322. border-radius: 12rpx;
  323. margin-bottom: 20rpx;
  324. padding: 20rpx;
  325. .order-header {
  326. display: flex;
  327. flex-direction: row;
  328. justify-content: space-between;
  329. align-items: center;
  330. padding-bottom: 20rpx;
  331. border-bottom: 1rpx solid #eee;
  332. .order-no {
  333. color: #06507b;
  334. font-size: 28rpx;
  335. }
  336. .copy-btn {
  337. color: #06507b;
  338. font-size: 24rpx;
  339. }
  340. }
  341. .order-info {
  342. padding: 20rpx 0;
  343. text {
  344. display: block;
  345. color: #666;
  346. font-size: 24rpx;
  347. line-height: 1.8;
  348. }
  349. }
  350. .download-btn {
  351. width: 28%;
  352. height: 15%;
  353. background-color: #044f7a;
  354. position: absolute;
  355. color: #ffffff;
  356. bottom: 10%;
  357. right: 10%;
  358. font-size: 0.5rem;
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. border-radius: 1rem;
  363. }
  364. }
  365. .status{
  366. position: absolute;
  367. width: 25%;
  368. height: 25%;
  369. right: 10%;
  370. top:30%
  371. }
  372. </style>