index.vue 9.3 KB

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