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

287 lines
6.3 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
  1. <template>
  2. <view class="container">
  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="activeTab = 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.orderNo }}</text>
  36. <text class="copy-btn" @tap="copyOrderNo(order.orderNo)">复制</text>
  37. </view>
  38. <view class="order-info">
  39. <text>客户姓名:{{ order.customerName }}</text>
  40. <text>联系方式:{{ order.phone }}</text>
  41. <text>服务名称:{{ order.serviceName }}</text>
  42. <text>订单时间:{{ order.orderTime }}</text>
  43. <text>销售人员:{{ order.salesman }}</text>
  44. <text>门店名称:{{ order.store }}</text>
  45. </view>
  46. <button class="download-btn" @tap="downloadPDF(order)">PDF下载</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. firstFocus:false,
  55. searchKey: '', // 搜索关键词
  56. activeTab: '全部', // 当前激活的标签
  57. tabs: ['全部', '已生效', '已失效'],
  58. orders: [/* 从接口获取的数据 */
  59. {
  60. customerName:"你可乐" ,
  61. orderNo:"1223333",
  62. phone:"",
  63. serviceName:"",
  64. orderTime:"",
  65. salesman:"",
  66. store:""
  67. },{
  68. customerName:"你可乐" ,
  69. orderNo:"1223333",
  70. phone:"",
  71. serviceName:"",
  72. orderTime:"",
  73. salesman:"",
  74. store:""
  75. }
  76. ]
  77. }
  78. },
  79. computed: {
  80. // 过滤后的订单列表
  81. filteredOrders() {
  82. return this.orders.filter(order => {
  83. const matchStatus = this.activeTab === '全部' ||
  84. order.status === this.activeTab
  85. const matchSearch = order.customerName.includes(this.searchKey) ||
  86. order.phone.includes(this.searchKey)
  87. return matchStatus && matchSearch
  88. })
  89. }
  90. },
  91. methods: {
  92. toBack(){
  93. let canNavBack = getCurrentPages()
  94. if( canNavBack && canNavBack.length>1) {
  95. uni.navigateBack()
  96. } else {
  97. history.back();
  98. }
  99. },
  100. // 搜索处理
  101. handleSearch() {
  102. // 实际调用接口获取数据
  103. console.log('搜索关键词:', this.searchKey)
  104. },
  105. // 复制订单号
  106. copyOrderNo(orderNo) {
  107. uni.setClipboardData({
  108. data: orderNo,
  109. success: () => {
  110. uni.showToast({ title: '复制成功' })
  111. }
  112. })
  113. },
  114. // PDF下载
  115. async downloadPDF(order) {
  116. uni.showLoading({ title: '下载中...' })
  117. try {
  118. // 1. 调用下载接口
  119. const { tempFilePath } = await uni.downloadFile({
  120. url: 'https://your-api.com/download',
  121. header: { 'order-id': order.id }
  122. })
  123. // 2. 保存到本地
  124. await uni.saveFile({
  125. tempFilePath,
  126. success: (res) => {
  127. uni.showToast({ title: '下载成功' })
  128. console.log('文件路径:', res.savedFilePath)
  129. }
  130. })
  131. // 3. 打开文档(可选)
  132. uni.openDocument({
  133. filePath: tempFilePath,
  134. showMenu: true
  135. })
  136. } catch (err) {
  137. uni.showToast({ title: '下载失败', icon: 'none' })
  138. } finally {
  139. uni.hideLoading()
  140. }
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .search-box {
  147. height: 10%;
  148. display: flex;
  149. flex-direction: row;
  150. margin-bottom: 30rpx;
  151. align-items: center;
  152. .search-input {
  153. flex: 1;
  154. background: #fff;
  155. padding: 20rpx;
  156. border-radius: 8rpx;
  157. }
  158. .search-btn {
  159. width: 20%;
  160. height: 40%;
  161. margin-right: 10%;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. font-size: 1rem;
  166. color: #044f7a;
  167. border: none;
  168. }
  169. .search-btn:after {
  170. border: none;
  171. }
  172. .isshow-header-content-icon{
  173. display: flex;
  174. justify-content: center;
  175. margin-left: 10%;
  176. align-items: center;
  177. }
  178. }
  179. .filter-tabs {
  180. display: flex;
  181. flex-direction: row;
  182. margin-bottom: 30rpx;
  183. position: relative;
  184. .tab-item {
  185. flex: 1;
  186. width: 10%;
  187. text-align: center;
  188. padding: 20rpx;
  189. color: #000000;
  190. border-bottom: 4rpx solid transparent;
  191. &.active {
  192. color: #044f7a;
  193. // border-bottom-color: #044f7a;
  194. }
  195. &.active:after {
  196. content: '';
  197. width: 50%;
  198. height: 1px;
  199. display: block;
  200. margin: 0 auto;
  201. border-bottom: 2px solid #044f7a;
  202. color: #044f7a;
  203. padding: 1px;
  204. }
  205. }
  206. }
  207. .order-item {
  208. margin: 0 auto;
  209. width: 80%;
  210. height: 30%;
  211. box-shadow: -0.1rem 0.1rem #e4e4e4;
  212. border: 1px solid #e1e1e1;
  213. border-radius: 0.5rem;
  214. position: relative;
  215. background: white;
  216. border-radius: 12rpx;
  217. margin-bottom: 20rpx;
  218. padding: 20rpx;
  219. .order-header {
  220. display: flex;
  221. flex-direction: row;
  222. justify-content: space-between;
  223. align-items: center;
  224. padding-bottom: 20rpx;
  225. border-bottom: 1rpx solid #eee;
  226. .order-no {
  227. color: #06507b;
  228. font-size: 28rpx;
  229. }
  230. .copy-btn {
  231. color: #06507b;
  232. font-size: 24rpx;
  233. }
  234. }
  235. .order-info {
  236. padding: 20rpx 0;
  237. text {
  238. display: block;
  239. color: #666;
  240. font-size: 24rpx;
  241. line-height: 1.8;
  242. }
  243. }
  244. .download-btn {
  245. width: 28%;
  246. height: 15%;
  247. background-color: #044f7a;
  248. position: absolute;
  249. color: #ffffff;
  250. bottom: 10%;
  251. right: 10%;
  252. font-size: 0.5rem;
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. border-radius: 1rem;
  257. }
  258. }
  259. </style>