合同小程序前端代码仓库
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
10 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 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" />
  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.id)" v-if='order.status == 0 ? true : false'>PDF下载</button>
  47. <image src="/static/image/组 71693.png" v-if='order.status == 0 ? true : false' class="status"></image>
  48. <image src="/static/image/组 71697.png" v-if='order.status == 0 ? 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. scrolltolower(){
  88. this.params.pageNo++
  89. console.log('pageNo', this.params.pageNo)
  90. uni.showLoading({
  91. title: '刷新中..'
  92. })
  93. list(this.params).then((res)=>{
  94. let orders = res.result.records;
  95. for (var index = 0; index < orders.length; index++) {
  96. this.orders.push(orders[index]);
  97. }
  98. uni.hideLoading();
  99. })
  100. },
  101. changeStatus(status){
  102. uni.showLoading();
  103. this.activeTab = status;
  104. if(status== '已生效'){
  105. this.orders.splice(0)
  106. this.params.status = 0;
  107. this.params.pageNo= 1;
  108. list(this.params).then((res)=>{
  109. let orders = res.result.records;
  110. for (var index = 0; index < orders.length; index++) {
  111. this.orders.push(orders[index]);
  112. }
  113. uni.hideLoading();
  114. })
  115. }else if (status== '已失效'){
  116. this.orders.splice(0);
  117. this.params.status = 1;
  118. this.params.pageNo= 1
  119. list(this.params).then((res)=>{
  120. for (var index = 0; index < res.result.records.length; index++) {
  121. this.orders.push(res.result.records[index]);
  122. }
  123. })
  124. uni.hideLoading();
  125. }else{
  126. this.params.status = '';
  127. this.params.pageNo= 1
  128. list(this.params).then((res)=>{
  129. console.log(res.result)
  130. this.orders.splice(0);
  131. for (var index = 0; index < res.result.records.length; index++) {
  132. this.orders.push(res.result.records[index]);
  133. }
  134. uni.hideLoading();
  135. })
  136. }
  137. },
  138. // 回退
  139. toBack(){
  140. let canNavBack = getCurrentPages()
  141. if( canNavBack && canNavBack.length>1) {
  142. uni.navigateBack()
  143. } else {
  144. history.back();
  145. }
  146. },
  147. IsChinese(value) {
  148. const reg = /^[\u4e00-\u9fa5]+$/gi;
  149. return reg.test(value);
  150. },
  151. WhNumber(value) {
  152. return /^\d+$/.test(value);
  153. },
  154. // 搜索处理
  155. handleSearch() {
  156. // 实际调用接口获取数据
  157. uni.showLoading();
  158. // console.log(this.IsChinese(this.searchKey));
  159. if(this.IsChinese(this.searchKey)){
  160. list({custName:this.searchKey,pageNo:1,pageSize:10}).then((res)=>{
  161. this.activeTab = '全部';
  162. this.orders.splice(0);
  163. let orders = res.result.records;
  164. for (var index = 0; index < orders.length; index++) {
  165. this.orders.push(orders[index]);
  166. }
  167. uni.hideLoading();
  168. })
  169. }else if(this.WhNumber(this.searchKey)){
  170. list({custPhone:this.searchKey,pageNo:1,pageSize:10}).then((res)=>{
  171. this.activeTab = '全部';
  172. this.orders.splice(0);
  173. let orders = res.result.records;
  174. for (var index = 0; index < orders.length; index++) {
  175. this.orders.push(orders[index]);
  176. }
  177. uni.hideLoading();
  178. })
  179. }else if(!this.searchKey){
  180. list({pageNo:1,pageSize:10}).then((res)=>{
  181. this.activeTab = '全部';
  182. this.orders.splice(0);
  183. let orders = res.result.records;
  184. for (var index = 0; index < orders.length; index++) {
  185. this.orders.push(orders[index]);
  186. }
  187. uni.hideLoading();
  188. })
  189. }
  190. },
  191. // 复制订单号
  192. copyorderNum(orderNum) {
  193. uni.setClipboardData({
  194. data: orderNum,
  195. success: () => {
  196. uni.showToast({ title: '复制成功' })
  197. }
  198. })
  199. },
  200. // PDF下载
  201. async downloadPDF(id) {
  202. uni.showLoading({ title: '下载中...' })
  203. // 1. 调用下载接口
  204. addContract({orderId:id}).then((res)=>{
  205. let url = res.message;
  206. uni.downloadFile({
  207. url: url,//下载地址接口返回
  208. success: (data) => {
  209. uni.saveFile({
  210. tempFilePath: data.tempFilePath, //临时路径
  211. // filePath:"内部存储/Documents/",
  212. success: (res)=> {
  213. uni.hideLoading();
  214. uni.showToast({
  215. icon: 'none',
  216. mask: true,
  217. title: '文件已下载,打开后请点击右上角保存!', //保存路径
  218. duration: 3000,
  219. });
  220. setTimeout(() => {
  221. //打开文档查看
  222. uni.openDocument({
  223. filePath: res.savedFilePath,
  224. showMenu:true,
  225. success: function(res) {
  226. list({pageNo:1,pageSize:10}).then((res)=>{
  227. for (var index = 0; index < res.result.records.length; index++) {
  228. this.orders.push( res.result.records[index])
  229. }
  230. })
  231. }
  232. });
  233. }, 3000)
  234. }
  235. })
  236. },
  237. fail: (err) => {
  238. console.log(err);
  239. uni.showToast({
  240. icon: 'none',
  241. mask: true,
  242. title: '失败请重新下载',
  243. });
  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>