index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="uForm" label-width="150">
  4. <u-card padding="0" :border="false" :foot-border-top="false" :head-border-bottom="false" >
  5. <view class="" slot="body">
  6. <u-form-item class="form-item" label="地区">
  7. <u-picker v-model="regionshow" mode="region" :default-region="defaultRegion" @confirm="regionConfirm" :params="regionParams"></u-picker>
  8. <select-addr
  9. ref="addr"
  10. @getAddr="getAddr"
  11. class="normal"
  12. >
  13. </select-addr>
  14. </u-form-item>
  15. <u-form-item class="form-item" label="开发年份">
  16. <u-picker v-model="devyearshow" mode="selector" :range="arrYear" :default-selector="[3]" @confirm="devyearConfirm"></u-picker>
  17. <view class="form-item-con" @click="devyearshow = true" v-if="!form.date">全部</view>
  18. <view class="form-item-con" @click="devyearshow = true">{{form.date}}</view>
  19. </u-form-item>
  20. <u-form-item class="form-item" label="售卖年份">
  21. <u-picker v-model="sellyearshow" mode="selector" :range="arrYear" :default-selector="[1]" @confirm="sellyearConfirm"></u-picker>
  22. <view class="form-item-con" @click="sellyearshow = true" v-if="!form.saleDate">全部</view>
  23. <view class="form-item-con" @click="sellyearshow = true">{{form.saleDate}}</view>
  24. </u-form-item>
  25. </view>
  26. </u-card>
  27. <u-card padding="0" :border="false" :foot-border-top="false" :head-border-bottom="false" class="statistics">
  28. <view class="" slot="body">
  29. <view class="title">
  30. <view class="title-left">统计</view>
  31. <view class="title-right">
  32. <text v-if="showText">{{showText}},</text>
  33. <text v-if="form.province!='选择地区'">{{form.province}},</text>
  34. <text>{{form.date||'全部'}}年<text v-if="!form.date">份</text>开发,</text>
  35. <text>{{form.saleDate||'全部'}}年<text v-if="!form.saleDate">份</text>售卖,</text>
  36. <text v-if="
  37. form.province!='选择地区'
  38. || form.date!='请选择'
  39. || form.saleDate!='请选择'
  40. ">的单株碳汇统计</text>
  41. </view>
  42. </view>
  43. <view class="statistics-block">
  44. <view class="statistics-block-til">已经开发的</view>
  45. <view class="statistics-item-wrap">
  46. <view class="statistics-item">
  47. <view class="statistics-item-til">已开发林户(户)</view>
  48. <view class="statistics-item-con">{{info.farmerNum||''}}</view>
  49. </view>
  50. <view class="statistics-item">
  51. <view class="statistics-item-til">已开发株数(株)</view>
  52. <view class="statistics-item-con">{{info.treeTotal||''}}</view>
  53. </view>
  54. </view>
  55. <view class="statistics-item-wrap">
  56. <view class="statistics-item">
  57. <view class="statistics-item-til">已开发涉及金额(元)</view>
  58. <view class="statistics-item-con">{{info.totalAmount||''}}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="statistics-block">
  63. <view class="statistics-block-til">已经售卖的</view>
  64. <view class="statistics-item-wrap">
  65. <view class="statistics-item">
  66. <view class="statistics-item-til">已有售出户数(户)</view>
  67. <view class="statistics-item-con">{{info.soldFarmerNum||''}}</view>
  68. </view>
  69. <view class="statistics-item">
  70. <view class="statistics-item-til">已有售出株数(株)</view>
  71. <view class="statistics-item-con">{{info.soldNum||''}}</view>
  72. </view>
  73. </view>
  74. <view class="statistics-item-wrap">
  75. <view class="statistics-item">
  76. <view class="statistics-item-til">已售出涉及金额(元)</view>
  77. <view class="statistics-item-con">{{info.soldAmount||''}}</view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="statistics-block">
  82. <view class="statistics-block-til">还剩余的</view>
  83. <view class="statistics-item-wrap">
  84. <view class="statistics-item">
  85. <view class="statistics-item-til">未有售出户数(户)</view>
  86. <view class="statistics-item-con">{{info.canSoldFarmerNum||''}}</view>
  87. </view>
  88. <view class="statistics-item">
  89. <view class="statistics-item-til">剩余可售卖株数(株)</view>
  90. <view class="statistics-item-con">{{info.canSoldNum||''}}</view>
  91. </view>
  92. </view>
  93. <view class="statistics-item-wrap">
  94. <view class="statistics-item">
  95. <view class="statistics-item-til">剩余涉及金额(元)</view>
  96. <view class="statistics-item-con">{{info.canSoldAmount||''}}</view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </u-card>
  102. </u-form>
  103. </view>
  104. </template>
  105. <script>
  106. import selectAddr from '@/components/select-addr/select-addr.vue'
  107. import {config} from '@/common/config.js'
  108. export default {
  109. components:{
  110. selectAddr
  111. },
  112. data() {
  113. return {
  114. regionshow:false,
  115. devyearshow:false,
  116. sellyearshow:false,
  117. defaultRegion:['贵州省'],
  118. form: {
  119. province:'选择地区',
  120. // provinceCode:'',
  121. date:'',
  122. saleDate:'',
  123. // cityId:'',
  124. // countyId:'',
  125. // townId:'',
  126. villageId:'',
  127. textArray:[],
  128. areaType:0,
  129. },
  130. // timeParams: {
  131. // year: true,
  132. // month: false,
  133. // day: false,
  134. // hour: false,
  135. // minute: false,
  136. // second: false
  137. // },
  138. regionParams: {
  139. province: true,
  140. city: false,
  141. area: false
  142. },
  143. info:new Object(),
  144. arrYear:[],
  145. showText:'',
  146. }
  147. },
  148. onLoad() {
  149. let myDate = new Date();
  150. let year = myDate.getFullYear();
  151. this.form.date=year-1;
  152. //获取某一年份到当前年份的所有年份
  153. var thisYear = myDate.getFullYear(); // 获取当年年份
  154. var Section = thisYear - 1976; // 声明一个变量 获得当前年份至想获取年份差 eg.1976
  155. for(var i = 0;i<=Section;i++){
  156. this.arrYear.push(thisYear--)
  157. }; // 遍历并添加年份到数组 arrYear里便是1976年到当前的所有年份了
  158. this.arrYear.unshift('全部');
  159. // 调用getInfo接口
  160. this.getInfo();
  161. },
  162. onReady() {
  163. // 预读取地址数据
  164. this.$u.get(config.addrApi,{}).then(res => {
  165. if (res.retHead.errCode == 0) {
  166. uni.setStorageSync('addrData', res.retBody);
  167. } else {
  168. this.$api.msg(res.retHead.errMsg)
  169. }
  170. });
  171. },
  172. methods: {
  173. getInfo:function(){
  174. this.$u.api.getInfo(this.form).then(res => {
  175. console.log('getInfo',JSON.parse(JSON.stringify(res.retBody)));
  176. this.info = res.retBody;
  177. }).catch(err=>{
  178. console.log(err)
  179. });
  180. },
  181. regionConfirm:function(e){
  182. console.log('regionConfirm',e);
  183. this.form.province = e.province.label;
  184. this.form.provinceCode = e.province.value;
  185. this.getInfo();
  186. },
  187. devyearConfirm:function(e){
  188. // console.log('devyearConfirm',e);
  189. // console.log('devyearConfirm arrYear',this.arrYear[e]);
  190. if(this.arrYear[e]=='全部'){
  191. this.form.date = '';
  192. }else{
  193. this.form.date = this.arrYear[e];
  194. }
  195. this.getInfo();
  196. },
  197. sellyearConfirm:function(e){
  198. // console.log('sellyearConfirm',e.year,);
  199. console.log('sellyearConfirm arrYear',this.arrYear[e]);
  200. if(this.arrYear[e]=='全部'){
  201. this.form.saleDate = '';
  202. }else{
  203. this.form.saleDate = this.arrYear[e];
  204. };
  205. if(this.arrYear[e]<this.form.date){
  206. this.$u.toast('不能小于开发年份!');
  207. this.form.saleDate = '';
  208. return false;
  209. };
  210. this.getInfo();
  211. },
  212. //获取地址选择组件数据
  213. getAddr(data){
  214. console.log('getAddr',JSON.parse(JSON.stringify(data)))
  215. // this.form.cityId = data.cityId;
  216. // this.form.countyId = data.countyId;
  217. // this.form.townId = data.townId;
  218. // this.form.villageId = data.villageId;
  219. this.form.textArray=data.textArray;
  220. let showTextIndex = data.textArray.length -1;
  221. // console.log(this.form.textArray[showTextIndex]);
  222. if(this.form.textArray[showTextIndex]){this.showText=this.form.textArray[showTextIndex]};
  223. this.form.areaType=data.addrLevel;
  224. if(this.form.areaType == 2){
  225. this.form.villageId = data.cityId;
  226. }else if(this.form.areaType == 3){
  227. this.form.villageId = data.countyId;
  228. }else if(this.form.areaType == 4){
  229. this.form.villageId = data.townId;
  230. }else if(this.form.areaType == 5){
  231. this.form.villageId = data.villageId;
  232. }else{
  233. this.form.villageId = "";
  234. };
  235. this.getInfo();
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. @import url('./index.css');
  242. </style>