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