index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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, openMessagePage } from '@/libs/tools'
  57. import { bizData } from '@/api/sales'
  58. import { listLookUp, getLookUpDatas } from '@/api/data.js'
  59. import { setReadNotice } from "@/api/user.js"
  60. export default{
  61. components: { ListComponent },
  62. data(){
  63. return{
  64. tabNav: [
  65. { name: '今日', ind: 0 },
  66. { name: '本周', ind: 1 },
  67. { name: '本月', ind: 2 }
  68. ],
  69. navInd: 0,
  70. bizData: null, // 销售数据统计
  71. theme: '',
  72. listHeight: 400
  73. }
  74. },
  75. onReady() {
  76. const query = uni.createSelectorQuery().in(this);
  77. query.select('#tjCons').boundingClientRect(data => {
  78. this.listHeight = Math.floor(data.height)
  79. }).exec();
  80. },
  81. onLoad(opts) {
  82. const _this = this
  83. this.$nextTick(function(){
  84. // 监听整改完成后刷新事件
  85. uni.$on('refreshSalesHomeBL', function(data){
  86. _this.$refs.salesList.refash()
  87. })
  88. })
  89. // 点击消息打开
  90. const msg = this.$store.state.vuex_tempData
  91. console.log('toMessage',msg)
  92. if(msg){
  93. setReadNotice({'noticeId': msg.extras.noticeId}).then(res => {
  94. openMessagePage(msg)
  95. })
  96. }
  97. // 底部tab
  98. const theme = getApp().globalData.theme
  99. this.theme = theme
  100. uni.setTabBarItem({
  101. "index": 0,
  102. "iconPath": "static/"+theme+"/tabbar/home.png",
  103. "selectedIconPath": "static/"+theme+"/tabbar/home-active.png",
  104. })
  105. uni.setTabBarItem({
  106. "index": 1,
  107. "iconPath": "static/"+theme+"/tabbar/stock.png",
  108. "selectedIconPath": "static/"+theme+"/tabbar/stock-active.png",
  109. "visible": this.$hasPermissions('M_stockManage_mobile')
  110. })
  111. uni.setTabBarItem({
  112. "index": 2,
  113. "iconPath": "static/"+theme+"/tabbar/shelf.png",
  114. "selectedIconPath": "static/"+theme+"/tabbar/shelf-active.png",
  115. "visible": this.$hasPermissions('M_shelfManage_mobile')
  116. })
  117. uni.setTabBarItem({
  118. "index": 3,
  119. "iconPath": "static/"+theme+"/tabbar/statistics.png",
  120. "selectedIconPath": "static/"+theme+"/tabbar/statistics-active.png",
  121. "visible": this.$hasPermissions('M_shelfManage_mobile')
  122. })
  123. uni.setTabBarItem({
  124. "index": 4,
  125. "iconPath": "static/"+theme+"/tabbar/user.png",
  126. "selectedIconPath": "static/"+theme+"/tabbar/user-active.png",
  127. })
  128. uni.setTabBarStyle({
  129. color: this.$config("topBarTitleColors"),
  130. selectedColor: this.$config("primaryColor"),
  131. borderStyle: 'white',
  132. complete: function(res){
  133. console.log(res)
  134. }
  135. })
  136. // 获取数据字典
  137. this.getListLookUp();
  138. // 获取支付,收款方式
  139. this.getLookUpList('SETTLE_STYLE', 'vuex_paymentTypeList');
  140. // 获取门店审核状态
  141. this.getLookUpList('XPRH_STORE_APPLY_STATUS', 'vuex_storeAuthState');
  142. // 门店审核结算方式
  143. this.getLookUpList('SHELF_SETTLE_TYPE', 'vuex_shelfSettleType');
  144. },
  145. onUnload() {
  146. uni.$off('refreshSalesHomeBL')
  147. uni.$off('toMessage')
  148. },
  149. onShow() {
  150. this.navInd = 0
  151. this.getBizData()
  152. },
  153. methods:{
  154. // 获取数据字典
  155. getListLookUp() {
  156. const _this = this;
  157. listLookUp().then(res => {
  158. if (res.status == 200) {
  159. _this.$store.state.vuex_allLookUp = res.data;
  160. }
  161. });
  162. },
  163. // 或某一项字典列表,参数code
  164. getLookUpList(code, vuexKey) {
  165. getLookUpDatas({ pageNo: 1,pageSize: 1000, lookupCode: code}).then(res => {
  166. console.log(res)
  167. if (res.status == 200) {
  168. const list = res.data.list;
  169. list.map(item => {
  170. item.count = 0
  171. })
  172. this.$store.state[vuexKey] = list || [];
  173. }
  174. });
  175. },
  176. seleteTime(val){
  177. this.navInd = val
  178. },
  179. toPage(url){
  180. uni.navigateTo({ url: url })
  181. },
  182. getBizData () {
  183. bizData({}).then(res => {
  184. if (res.status == 200) {
  185. this.bizData = res.data || null
  186. } else {
  187. this.bizData = null
  188. }
  189. uni.stopPullDownRefresh();
  190. })
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .sales-warp{
  197. width: 100%;
  198. height: 100vh;
  199. padding: 0 20upx;
  200. > view{
  201. &:first-child{
  202. padding-top: 20upx;
  203. }
  204. }
  205. .color_6{
  206. color: #666;
  207. }
  208. .font_13{
  209. font-size: 26upx;
  210. }
  211. .content-data{
  212. background-color: #fff;
  213. padding: 20upx 20upx;
  214. border-radius: 20upx;
  215. box-shadow: 3upx 2upx 6upx #eee;
  216. margin-bottom: 20upx;
  217. .date-type{
  218. margin: 0 120upx 20upx;
  219. border-radius: 50upx;
  220. border: 1upx solid #eee;
  221. text{
  222. display: inline-block;
  223. padding: 10upx 0;
  224. width: 33%;
  225. text-align: center;
  226. }
  227. text:first-child{
  228. border-top-left-radius: 50upx;
  229. border-bottom-left-radius: 50upx;
  230. }
  231. text:last-child{
  232. border-top-right-radius: 50upx;
  233. border-bottom-right-radius: 50upx;
  234. }
  235. text:not(:last-child){
  236. border-right: 1upx solid #eee;
  237. }
  238. .active_day {
  239. background: rgb(0, 122, 255);
  240. color: #fff;
  241. }
  242. }
  243. .total{
  244. display: flex;
  245. .item-box{
  246. text-align: center;
  247. width: 50%;
  248. color:#999;
  249. }
  250. .item-box:first-child{
  251. border-right: 1px solid #e4e7ed;
  252. }
  253. }
  254. }
  255. .nav-cont{
  256. .nav-item{
  257. width: 49%;
  258. border-radius: 25upx;
  259. background-color: #ffffff;
  260. padding: 14upx 0;
  261. box-shadow: 3upx 2upx 6upx #eee;
  262. margin-bottom: 20upx;
  263. text-align: center;
  264. .nav-pic{
  265. margin: 0 auto;
  266. }
  267. .nav-txt{
  268. font-size: 28upx;
  269. color: #666666;
  270. }
  271. }
  272. }
  273. .sales-list{
  274. .title{
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-between;
  278. .title-name{
  279. font-size: 32upx;
  280. color: #333;
  281. font-weight: 1000;
  282. }
  283. .title-all{
  284. color: rgb(144, 147, 153);
  285. }
  286. }
  287. }
  288. }
  289. </style>