index.vue 9.4 KB

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