index.vue 9.7 KB

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