index.vue 10 KB

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