index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="sales-warp">
  3. <view id="tjCons">
  4. <!--销售数据统计 -->
  5. <view class="content-data" v-if="$hasPermissions('M_salesTj_mobile')">
  6. <view class="date-type">
  7. <text v-for="(item, index) in tabNav" :key="index" :class="[index == navInd ? 'active_day' : '']" @click="seleteTime(index)">{{item.name}}</text>
  8. </view>
  9. <view class="total">
  10. <view class="item-box">
  11. <u-count-to v-if="navInd==0" :end-val="bizData&&bizData.sales&&(bizData.sales.dayTotalQty || bizData.sales.dayTotalQty==0) ? bizData.sales.dayTotalQty : 0" separator=","></u-count-to>
  12. <u-count-to v-if="navInd==1" :end-val="bizData&&bizData.sales&&(bizData.sales.weekSalesQty || bizData.sales.weekSalesQty==0) ? bizData.sales.weekSalesQty : 0" separator=","></u-count-to>
  13. <u-count-to v-if="navInd==2" :end-val="bizData&&bizData.sales&&(bizData.sales.monthSalesQty || bizData.sales.monthSalesQty==0) ? bizData.sales.monthSalesQty : 0" separator=","></u-count-to>
  14. <view>销售总单量(个)</view>
  15. </view>
  16. <view class="item-box">
  17. <u-count-to v-if="navInd==0" :end-val="bizData&&bizData.sales&&(bizData.sales.dayTotalAmount || bizData.sales.dayTotalAmount==0) ? bizData.sales.dayTotalAmount : 0" separator="," :decimals="2"></u-count-to>
  18. <u-count-to v-if="navInd==1" :end-val="bizData&&bizData.sales&&(bizData.sales.weekSalesAmount || bizData.sales.weekSalesAmount==0) ? bizData.sales.weekSalesAmount : 0" separator="," :decimals="2"></u-count-to>
  19. <u-count-to v-if="navInd==2" :end-val="bizData&&bizData.sales&&(bizData.sales.monthSalesAmount || bizData.sales.monthSalesAmount==0) ? bizData.sales.monthSalesAmount : 0" separator="," :decimals="2"></u-count-to>
  20. <view>销售总金额(¥)</view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 产品报价及新增销售单 -->
  25. <view class="nav-cont flex align_center justify_between">
  26. <view class="nav-item" @click="toPage('/pages/sales/productPricing')" v-if="$hasPermissions('M_productPrice_mobile')">
  27. <u-image class="nav-pic" style="margin-top: 5upx;" :src="`../../static/${theme}/navIcon/price_icon.png`" width="60" height="60"></u-image>
  28. <text class="nav-txt" style="margin-top: 5upx;">产品报价</text>
  29. </view>
  30. <!-- <view class="nav-item" @click="toPage('/pages/sales/chooseCustomer')">
  31. <u-image class="nav-pic" :src="`../../static/${theme}/navIcon/sale_icon.png`" width="70" height="70"></u-image>
  32. <text class="nav-txt">新增销售单</text>
  33. </view> -->
  34. <view class="nav-item" @click="toPage('/pages/webviews/openview?title=产品查询&url=https://jgqp.51cjml.com/h5/#!/')" v-if="$hasPermissions('M_queryProduct_mobile')">
  35. <u-image class="nav-pic" :src="`../../static/${theme}/navIcon/pfind.png`" width="64" height="64"></u-image>
  36. <text class="nav-txt">产品查询</text>
  37. </view>
  38. </view>
  39. <!-- 销售单 -->
  40. <view class="sales-list">
  41. <view class="title">
  42. <text class="title-name" @click="$refs.salesList.refash()">
  43. 销售单
  44. <u-icon name="reload" color="#2979ff" size="28"></u-icon>
  45. </text>
  46. <view class="title-all" @click="toPage('/pages/sales/list')">查看全部<u-icon name="arrow-right" color="rgb(144, 147, 153)" size="28"></u-icon></view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 销售单列表 -->
  51. <listComponent ref="salesList" :height="listHeight" />
  52. </view>
  53. </template>
  54. <script>
  55. import ListComponent from './listComponent.vue'
  56. import { toThousands } from '@/libs/tools'
  57. import { bizData } from '@/api/sales'
  58. import { listLookUp, getLookUpDatas } from '@/api/data.js'
  59. export default{
  60. components: { ListComponent },
  61. data(){
  62. return{
  63. tabNav: [
  64. { name: '今日', ind: 0 },
  65. { name: '本周', ind: 1 },
  66. { name: '本月', ind: 2 }
  67. ],
  68. navInd: 0,
  69. bizData: null, // 销售数据统计
  70. theme: '',
  71. listHeight: 400
  72. }
  73. },
  74. onReady() {
  75. const query = uni.createSelectorQuery().in(this);
  76. query.select('#tjCons').boundingClientRect(data => {
  77. this.listHeight = Math.floor(data.height)
  78. }).exec();
  79. },
  80. onLoad() {
  81. const _this = this
  82. this.$nextTick(function(){
  83. // 监听整改完成后刷新事件
  84. uni.$on('refreshSalesHomeBL', function(data){
  85. _this.$refs.salesList.refash()
  86. })
  87. })
  88. const theme = getApp().globalData.theme
  89. this.theme = theme
  90. uni.setTabBarItem({
  91. "index": 0,
  92. "iconPath": "static/"+theme+"/tabbar/home.png",
  93. "selectedIconPath": "static/"+theme+"/tabbar/home-active.png",
  94. })
  95. uni.setTabBarItem({
  96. "index": 1,
  97. "iconPath": "static/"+theme+"/tabbar/stock.png",
  98. "selectedIconPath": "static/"+theme+"/tabbar/stock-active.png",
  99. "visible": this.$hasPermissions('M_stockManage_mobile')
  100. })
  101. uni.setTabBarItem({
  102. "index": 2,
  103. "iconPath": "static/"+theme+"/tabbar/shelf.png",
  104. "selectedIconPath": "static/"+theme+"/tabbar/shelf-active.png",
  105. "visible": this.$hasPermissions('M_shelfManage_mobile')
  106. })
  107. uni.setTabBarItem({
  108. "index": 3,
  109. "iconPath": "static/"+theme+"/tabbar/user.png",
  110. "selectedIconPath": "static/"+theme+"/tabbar/user-active.png",
  111. })
  112. uni.setTabBarStyle({
  113. color: this.$config("topBarTitleColors"),
  114. selectedColor: this.$config("primaryColor"),
  115. borderStyle: 'white',
  116. complete: function(res){
  117. console.log(res)
  118. }
  119. })
  120. // 获取数据字典
  121. this.getListLookUp();
  122. // 获取支付,收款方式
  123. this.getLookUpList('SETTLE_STYLE', 'vuex_paymentTypeList');
  124. // 获取门店审核状态
  125. this.getLookUpList('XPRH_STORE_APPLY_STATUS', 'vuex_storeAuthState');
  126. // 门店审核结算方式
  127. this.getLookUpList('SHELF_SETTLE_TYPE', 'vuex_shelfSettleType');
  128. },
  129. onUnload() {
  130. uni.$off('refreshSalesHomeBL')
  131. },
  132. onShow() {
  133. this.navInd = 0
  134. this.getBizData()
  135. },
  136. methods:{
  137. // 获取数据字典
  138. getListLookUp() {
  139. const _this = this;
  140. listLookUp().then(res => {
  141. if (res.status == 200) {
  142. _this.$store.state.vuex_allLookUp = res.data;
  143. }
  144. });
  145. },
  146. // 或某一项字典列表,参数code
  147. getLookUpList(code, vuexKey) {
  148. getLookUpDatas({ pageNo: 1,pageSize: 1000, lookupCode: code}).then(res => {
  149. console.log(res)
  150. if (res.status == 200) {
  151. const list = res.data.list;
  152. list.map(item => {
  153. item.count = 0
  154. })
  155. this.$store.state[vuexKey] = list || [];
  156. }
  157. });
  158. },
  159. seleteTime(val){
  160. this.navInd = val
  161. },
  162. toPage(url){
  163. uni.navigateTo({ url: url })
  164. },
  165. getBizData () {
  166. bizData({}).then(res => {
  167. if (res.status == 200) {
  168. this.bizData = res.data || null
  169. } else {
  170. this.bizData = null
  171. }
  172. uni.stopPullDownRefresh();
  173. })
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. .sales-warp{
  180. width: 100%;
  181. height: 100vh;
  182. padding: 0 20upx;
  183. > view{
  184. &:first-child{
  185. padding-top: 20upx;
  186. }
  187. }
  188. .color_6{
  189. color: #666;
  190. }
  191. .font_13{
  192. font-size: 26upx;
  193. }
  194. .content-data{
  195. background-color: #fff;
  196. padding: 20upx 20upx;
  197. border-radius: 20upx;
  198. box-shadow: 3upx 2upx 6upx #eee;
  199. margin-bottom: 20upx;
  200. .date-type{
  201. margin: 0 120upx 20upx;
  202. border-radius: 50upx;
  203. border: 1upx solid #eee;
  204. text{
  205. display: inline-block;
  206. padding: 10upx 0;
  207. width: 33%;
  208. text-align: center;
  209. }
  210. text:first-child{
  211. border-top-left-radius: 50upx;
  212. border-bottom-left-radius: 50upx;
  213. }
  214. text:last-child{
  215. border-top-right-radius: 50upx;
  216. border-bottom-right-radius: 50upx;
  217. }
  218. text:not(:last-child){
  219. border-right: 1upx solid #eee;
  220. }
  221. .active_day {
  222. background: rgb(0, 122, 255);
  223. color: #fff;
  224. }
  225. }
  226. .total{
  227. display: flex;
  228. .item-box{
  229. text-align: center;
  230. width: 50%;
  231. color:#999;
  232. }
  233. .item-box:first-child{
  234. border-right: 1px solid #e4e7ed;
  235. }
  236. }
  237. }
  238. .nav-cont{
  239. .nav-item{
  240. width: 49%;
  241. border-radius: 25upx;
  242. background-color: #ffffff;
  243. padding: 14upx 0;
  244. box-shadow: 3upx 2upx 6upx #eee;
  245. margin-bottom: 20upx;
  246. text-align: center;
  247. .nav-pic{
  248. margin: 0 auto;
  249. }
  250. .nav-txt{
  251. font-size: 28upx;
  252. color: #666666;
  253. }
  254. }
  255. }
  256. .sales-list{
  257. .title{
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. .title-name{
  262. font-size: 32upx;
  263. color: #333;
  264. font-weight: 1000;
  265. }
  266. .title-all{
  267. color: rgb(144, 147, 153);
  268. }
  269. }
  270. }
  271. }
  272. </style>