index.vue 10 KB

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