accounting.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="mainBox">
  3. <view class="uni-padding-wrap uni-common-mt" style="margin: 10px;">
  4. <uni-segmented-control :current="current" :values="items" style-type="button" active-color="#007aff"
  5. @clickItem="onClickItem" />
  6. </view>
  7. <view v-if="current===0">
  8. <uni-card>
  9. <uni-forms ref="baseForm" label-position="left">
  10. <uni-forms-item label="姓名">
  11. <uni-easyinput v-model="form.lrXm" placeholder="请输入姓名" @input="fiflterData" />
  12. </uni-forms-item>
  13. <uni-forms-item label="用餐时间">
  14. <uni-datetime-picker type="date" :clear-icon="false" v-model="form.ychz" @change="getList()" />
  15. </uni-forms-item>
  16. </uni-forms>
  17. <view class="flexStyle">
  18. <view class="boxStyle">消费人次:{{this.total}}次</view>
  19. <view class="boxStyle">消费金额:{{this.allPrice}}元</view>
  20. <view class="boxStyle">优惠次数:{{this.btcs}}次</view>
  21. <view class="boxStyle">优惠金额:{{this.allYhje}}元</view>
  22. </view>
  23. <!-- <button type="primary" class="buttonStyle" @click="search()">搜索</button> -->
  24. </uni-card>
  25. <uni-card style="height: 60vh;overflow-y: auto;">
  26. <uni-card v-for="(item,index) in tableData" :key="index" :title="item.xm" :isFull="true" :sub-title="item.lrCydh" :extra="item.jylx"
  27. style="margin-top: 10px;margin-bottom: 20px;"
  28. :thumbnail="config.baseUrl+item.zpurl">
  29. <view class="flexStyle">
  30. <view class="boxStyle">用餐金额:{{item.ycje}}元</view>
  31. <view class="boxStyle">优惠金额:{{item.yhje}}元</view>
  32. <view class="boxStyle2">优惠类型:{{item.ssqhMc}}</view>
  33. <view class="boxStyle2">用餐时间:{{item.ycsj}}</view>
  34. </view>
  35. </uni-card>
  36. </uni-card>
  37. </view>
  38. <view v-if="current===1">
  39. <uni-card>
  40. <uni-forms ref="baseForm" label-position="top">
  41. <uni-forms-item label="用餐时间">
  42. <uni-datetime-picker type="daterange" :clear-icon="false" v-model="ychz" @change="getList2()" />
  43. </uni-forms-item>
  44. </uni-forms>
  45. <!-- <button type="primary" class="buttonStyle" @click="search()">搜索</button> -->
  46. </uni-card>
  47. <uni-card style="height: 70vh;overflow-y: auto;">
  48. <uni-card v-for="(item,index) in tableData2" :key="index" :title="item.label" :isFull="true" :extra="item.value1+'人用餐'"
  49. style="margin-top: 10px;margin-bottom: 20px;">
  50. <!-- <view class="flexStyle"> -->
  51. <!-- <view>用餐人次:28186次</view> -->
  52. <view>用餐金额:{{item.value2}}元</view>
  53. <view>优惠金额:{{item.value3}}元</view>
  54. <view >实际消费金额:{{item.value4}}元</view>
  55. <!-- </view> -->
  56. </uni-card>
  57. </uni-card>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. getUser
  64. } from '@/common/auth.js'
  65. import {
  66. ycListByLnst,getstatisticaldata
  67. } from '@/api/kh.js'
  68. import {
  69. decryptRowData_ECB
  70. } from '@/common/sm4.js'
  71. export default {
  72. components: {},
  73. data() {
  74. return {
  75. items: ['用餐对账', '用餐信息统计'],
  76. current: 0,
  77. status: 'more',
  78. isShow: false,
  79. ychz:[],
  80. form:{
  81. stbm: '',
  82. lrXm: '',
  83. ychz: '',
  84. },
  85. queryParams:{
  86. dictType: 'ST014',
  87. para1: null,
  88. para2: null,
  89. para3:'1' ,
  90. para4:'',
  91. },
  92. tableData: [],
  93. oldtableData: [],
  94. tableData2:[],
  95. total: 0,
  96. allPrice:0,
  97. allYhje:0,
  98. btcs:0,
  99. }
  100. },
  101. onLoad: function(options) {
  102. this.userInfo = getUser()
  103. this.form.stbm = this.userInfo.stbm;
  104. this.queryParams.para4=this.userInfo.stbm;
  105. this.form.ychz = this.getCurrentDate();
  106. this.getCurrentDate2();
  107. this.getList()
  108. this.getList2()
  109. },
  110. methods: {
  111. onClickItem(e) {
  112. if (this.current !== e.currentIndex) {
  113. this.current = e.currentIndex
  114. }
  115. },
  116. getCurrentDate2(){
  117. const dateMat = new Date();
  118. const yearA = dateMat.getFullYear();
  119. const monthA = dateMat.getMonth() + 1 > 9 ? dateMat.getMonth() + 1 : '0' + (dateMat.getMonth() + 1);
  120. const dayA = dateMat.getDate() > 9 ? dateMat.getDate() : '0' + dateMat.getDate();
  121. let year = dateMat.getFullYear();
  122. let month = dateMat.getMonth(); // 月份从0开始,即0代表1月,1代表2月,依此类推
  123. let day = dateMat.getDate();
  124. // 如果是1月,设置年份为去年,月份为11(12-1)
  125. if (month === 0) {
  126. year -= 1;
  127. month = 11;
  128. } else {
  129. month -= 1; // 否则,月份减1
  130. }
  131. // 计算上个月的日期,如果当前是月末,取上个月的最后一天
  132. if (day === new Date(year, month + 1, 0).getDate()) {
  133. day = new Date(year, month, 0).getDate(); // 获取上个月的最后一天
  134. }
  135. // 格式化日期
  136. const monthStr = month + 1 > 9 ? month + 1 : '0' + (month + 1);
  137. const dayStr = day > 9 ? day : '0' + day;
  138. this.queryParams.para1 = year +'-'+ monthStr +'-'+ dayStr;
  139. this.queryParams.para2 = yearA + '-'+monthA + '-'+dayA;
  140. this.ychz=[this.queryParams.para1,this.queryParams.para2]
  141. },
  142. getCurrentDate() {
  143. const date = new Date();
  144. const dateMap = {
  145. year: date.getFullYear(),
  146. month: date.getMonth() + 1,
  147. day: date.getDate(),
  148. };
  149. const month = dateMap.month >= 10 ? dateMap.month : "0" + dateMap.month;
  150. const day = dateMap.day >= 10 ? dateMap.day : "0" + dateMap.day;
  151. return dateMap.year.toString() + '-' + month.toString() + '-' + day.toString();
  152. },
  153. search() {
  154. this.dataList = []
  155. this.getList()
  156. },
  157. fiflterData(event){
  158. if(event)
  159. {
  160. this.tableData=[];
  161. this.oldtableData.map(item=> {
  162. if(item.xm.indexOf(event)!==-1){
  163. this.tableData.push(item)
  164. }
  165. })
  166. }else
  167. {
  168. this.tableData=JSON.parse(JSON.stringify(this.oldtableData))
  169. }
  170. },
  171. getList() {
  172. this.total=0;
  173. this.btcs=0;
  174. this.allPrice=0;
  175. this.allYhje=0;
  176. this.form.lrXm='';
  177. uni.showLoading({
  178. title: '加载中...',
  179. mask: true,
  180. })
  181. ycListByLnst({
  182. ...this.form,
  183. ychz: this.form.ychz.replace(new RegExp('-', 'g'), '')
  184. }).then(res => {
  185. uni.hideLoading();
  186. if (res.code == 200) {
  187. let list = decryptRowData_ECB(res.rows, ["xm","lrCydh"], [1,4])
  188. this.tableData=list.map(item=>{
  189. this.allPrice+=Number(item.ycje);
  190. this.allYhje+=Number(item.yhje);
  191. if(item.btlx!=='2200000'){ this.btcs++; }
  192. return {...item,ycsj:this.special(item.ycsj)}
  193. });
  194. this.oldtableData=JSON.parse(JSON.stringify(this.tableData))
  195. this.total = res.total;
  196. }
  197. })
  198. },
  199. special(data){
  200. let time="";
  201. if(data&&data.length>=14)
  202. {
  203. time=data.slice(0,data.length-10)+'-'+data.slice(-10,-8)+'-'+data.slice(-8,-6)
  204. time+=" "+data.slice(-6,-4)+':'+data.slice(-4,-2)+':'+data.slice(-2)
  205. }
  206. return time;
  207. },
  208. getList2(){
  209. uni.showLoading({
  210. title: '加载中...',
  211. mask: true,
  212. })
  213. getstatisticaldata({
  214. ...this.queryParams,
  215. para1: this.ychz[0].replace(new RegExp('-', 'g'), ''),
  216. para2: this.ychz[1].replace(new RegExp('-', 'g'), ''),
  217. }).then(res => {
  218. uni.hideLoading();
  219. if (res.code == 200) {
  220. this.tableData2=res.data[1].rowList.map(item=>{
  221. return{label:item[0],value1:item[1],value2:item[2],value3:item[3],value4:item[4]}
  222. })
  223. }
  224. })
  225. }
  226. },
  227. watch: {},
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .mainBox {
  232. height: 100vh;
  233. width: 100%;
  234. overflow: hidden;
  235. }
  236. .uni-forms-item {
  237. margin-bottom: 12px;
  238. }
  239. .buttonStyle {
  240. height: 40px;
  241. line-height: 40px;
  242. }
  243. .flexStyle {
  244. display: flex;
  245. flex-direction: row;
  246. flex-wrap: wrap;
  247. justify-content: space-between;
  248. .boxStyle {
  249. margin-bottom: 8px;
  250. width: 50%;
  251. }
  252. .boxStyle2 {
  253. margin-bottom: 8px;
  254. width: 100%;
  255. }
  256. }
  257. .item-right {
  258. width: 60px;
  259. display: flex;
  260. flex-direction: column;
  261. background-position: left;
  262. background-size: 58px 58px;
  263. background-repeat: no-repeat;
  264. position: relative;
  265. font-size: 14px;
  266. .item-img {
  267. position: absolute;
  268. right: -5px;
  269. bottom: -10px;
  270. height: 40px;
  271. width: 40px;
  272. }
  273. }
  274. </style>