invData.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="new-report" v-loading="state.loading" style="min-height:300px">
  3. <div v-if="!state.error && isShow">
  4. <div v-loading="dayCompanyLoading">
  5. <div class="main-title">
  6. <p class="title">业务公司开票(每日)</p>
  7. <div style="display: flex;">
  8. <ElDatePicker style="width:135px" placeholder="日期" v-model="companyDayDate" :clearable="false"
  9. @change="requestCompanyDay" size="mini" datetype="year" value-format="yyyy-MM-dd" />
  10. </div>
  11. </div>
  12. <el-table size="small" border :data="dayCompany">
  13. <el-table-column label="业务公司" prop="companyName" width="160px" show-overflow-tooltip />
  14. <el-table-column label="开票金额" min-width="80px">
  15. <template slot-scope="scope">
  16. {{ scope.row.dayinfo.inv_fee }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="开票金额(退)" min-width="100px">
  20. <template slot-scope="scope">
  21. {{ scope.row.dayinfo.return_inv_fee }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="成本金额" min-width="80px">
  25. <template slot-scope="scope">
  26. {{ scope.row.dayinfo.cost_fee }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="成本金额(退)" min-width="100px">
  30. <template slot-scope="scope">
  31. {{ scope.row.dayinfo.return_cost_fee }}
  32. </template>
  33. </el-table-column>
  34. </el-table>
  35. </div>
  36. <div v-loading="dayCompanyLoading">
  37. <div class="main-title" style="flex-wrap: wrap;">
  38. <p class="title">业务公司开票(每月)</p>
  39. <div style="display: flex;">
  40. <ElSelect v-model="monthCompanyNo" @change="requestCompanyMonth" size="mini" style="margin-right: 10px">
  41. <ElOption v-for="comp in companies" :label="comp.companyName" :value="comp.companyNo" />
  42. </ElSelect>
  43. <ElDatePicker size="mini" style="width:135px" placeholder="日期" v-model="companyMonthDate" :clearable="false"
  44. @change="requestCompanyMonth" value-format="yyyy" type="year" />
  45. </div>
  46. </div>
  47. <el-table size="small" border :data="monthCompany">
  48. <el-table-column label="月份" width="80px" show-overflow-tooltip>
  49. <template slot-scope="scope">
  50. {{ scope.row.year }}-{{ String(scope.row.month).length === '1' ? '0' + scope.row.month : scope.row.month
  51. }}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="开票指标" min-width="80px" show-overflow-tooltip prop="inv_tips" />
  55. <el-table-column label="开票金额" min-width="80px" show-overflow-tooltip>
  56. <template slot-scope="scope">
  57. {{ scope.row.month_info.month_inv_fee }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="开票金额(退)" min-width="100px" show-overflow-tooltip>
  61. <template slot-scope="scope">
  62. {{ scope.row.month_info.month_return_inv_fee }}
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="成本指标" min-width="80px" show-overflow-tooltip prop="cost_tips" />
  66. <el-table-column label="成本金额" min-width="80px" show-overflow-tooltip>
  67. <template slot-scope="scope">
  68. {{ scope.row.month_info.month_cost_fee }}
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="成本金额(退)" min-width="100px" show-overflow-tooltip>
  72. <template slot-scope="scope">
  73. {{ scope.row.month_info.month_return_cost_fee }}
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. </div>
  78. <div v-loading="dayAccountLoading">
  79. <div class="main-title">
  80. <p class="title">业务经理开票(每日)</p>
  81. <ElDatePicker style="width:135px" placeholder="日期" v-model="dayDate" :clearable="false"
  82. @change="requestAccountDay" size="mini" value-format="yyyy-MM-dd" />
  83. </div>
  84. <el-table size="small" border :data="dayAccount">
  85. <el-table-column label="用户" prop="uname" width="100px" show-overflow-tooltip />
  86. <el-table-column label="开票金额" min-width="80px">
  87. <template slot-scope="scope">
  88. {{ scope.row.dayinfo.inv_fee }}
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="开票金额(退)" min-width="100px">
  92. <template slot-scope="scope">
  93. {{ scope.row.dayinfo.return_inv_fee }}
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="成本金额" min-width="80px">
  97. <template slot-scope="scope">
  98. {{ scope.row.dayinfo.cost_fee }}
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="成本金额(退)" min-width="100px">
  102. <template slot-scope="scope">
  103. {{ scope.row.dayinfo.return_cost_fee }}
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. </div>
  108. <div v-loading="monthLoading" style="margin-top: 10px">
  109. <div class="main-title" style="flex-wrap: wrap;">
  110. <p class="title">业务经理开票(每月)</p>
  111. <div style="display: flex;justify-self: end;">
  112. <UserSelect :value.sync="monthUser" :year="monthDate" style="margin-right: 10px"
  113. @change="requestAccountMonth" @clear="monthAccount = []" />
  114. <ElDatePicker size="mini" style="width:135px" placeholder="日期" v-model="monthDate" :clearable="false"
  115. @change="requestAccountMonth" value-format="yyyy" type="year" />
  116. </div>
  117. </div>
  118. <el-table size="small" border :data="monthAccount">
  119. <el-table-column label="月份" prop="month" width="100px" show-overflow-tooltip />
  120. <el-table-column label="开票金额" min-width="80px" prop="month_inv_fee" />
  121. <el-table-column label="开票金额(退)" min-width="100px" prop="month_return_inv_fee" />
  122. <el-table-column label="成本金额" min-width="80px" prop="month_cost_fee" />
  123. <el-table-column label="成本金额(退)" min-width="100px" prop="month_return_cost_fee" />
  124. </el-table>
  125. </div>
  126. </div>
  127. <template v-else-if="!state.loading">
  128. <unusual-state :hasPermission="isShow" :message="state.message" path="newReport" />
  129. </template>
  130. </div>
  131. </template>
  132. <script>
  133. import PeriodDatePicker from "../components/period-date-picker";
  134. import dayjs from "dayjs"
  135. import UnusualState from "@/components/unusual/index.vue";
  136. import { getOpenid, getParameterByName, removeOpenid, setOpenid } from "../utils/auth";
  137. import asyncRequest from "@/api/newResults";
  138. import userRequest from "@/api/index";
  139. import UserSelect from "@/components/userSelect/index.vue"
  140. // import { ElDatePicker } from "element-ui/types/date-picker";
  141. export default {
  142. name: "invData",
  143. components: {
  144. PeriodDatePicker,
  145. UnusualState,
  146. UserSelect
  147. },
  148. data() {
  149. return {
  150. zxTotal: 0,
  151. isDisplay: false,
  152. companies: [],
  153. monthCompanyNo: '',
  154. companyMonthLoading: false,
  155. companyMonthDate: '',
  156. monthCompany: [],
  157. dayCompanyNo: '',
  158. companyDayLoading: false,
  159. companyDayDate: '',
  160. dayCompany: [],
  161. monthUser: '',
  162. monthAccount: [],
  163. monthLoading: false,
  164. monthDate: '',
  165. dayAccountLoading: false,
  166. dayAccount: [],
  167. dayDate: '',
  168. state:{
  169. message: '',
  170. error: false,
  171. loading: false
  172. }
  173. };
  174. },
  175. mounted() {
  176. document.title = "数据统计"
  177. if(!getParameterByName('code')){ this.login() }else{
  178. this.requestUserinfo()
  179. }
  180. this.dayDate = dayjs(new Date()).format("YYYY-MM-DD")
  181. this.monthDate = dayjs(new Date()).format("YYYY")
  182. this.companyDayDate = dayjs(new Date()).format("YYYY-MM-DD")
  183. this.companyMonthDate = dayjs(new Date()).format("YYYY")
  184. },
  185. methods: {
  186. async requestCompanyDay() {
  187. this.companyDayLoading = true
  188. const { data, code } = await asyncRequest.everyCompanyDay({ daytime: this.companyDayDate })
  189. this.companyDayLoading = false
  190. if (code === 0) { this.dayCompany = data }
  191. },
  192. async requestCompanyMonth() {
  193. this.companyMonthLoading = true
  194. const { data, code } = await asyncRequest.everyCompanMonth({ year: this.companyMonthDate, companyNo: this.monthCompanyNo })
  195. this.companyMonthLoading = false
  196. if (code === 0) { this.monthCompany = data }
  197. },
  198. async requestAccountDay(){
  199. this.dayAccountLoading = true
  200. const { data, code } = await asyncRequest.everyAccountDay({ daytime: this.dayDate })
  201. this.dayAccountLoading = false
  202. if (code === 0) { this.dayAccount = data }
  203. },
  204. async requestAccountMonth() {
  205. if (this.monthDate !== '2025'){
  206. console.log('joined', this.monthUser)
  207. this.monthAccount = []
  208. return
  209. }
  210. this.monthAccountLoading = true
  211. const { data, code } = await asyncRequest.everyAccountMonth({ year: this.monthDate, uid: this.monthUser })
  212. this.monthAccountLoading = false
  213. if (code === 0) { this.monthAccount = data }
  214. },
  215. async requestData(){
  216. this.requestAccountDay()
  217. // this.requestAccountMonth()
  218. this.requestCompanyDay()
  219. this.requestCompanyMonth()
  220. // const data = await asyncRequest.everyAccountMonth({ year: '2025' })
  221. },
  222. async time(e) {
  223. const { startTime, endTime } = e;
  224. this.start = startTime || "";
  225. this.end = endTime || "";
  226. const { start, end } = this;
  227. if ((start !== "" && end === "") || (start === "" && end !== "")) {
  228. this.$message.warning("时间区间不完整!");
  229. this.date = []
  230. return;
  231. }
  232. if(this.start && this.end){
  233. this.date = [this.start + " 00:00:00", this.end + " 23:59:59"]
  234. }else{
  235. this.date = [this.start, this.end]
  236. }
  237. },
  238. async requestUserinfo(){
  239. this.state.loading = true;
  240. const openid = getOpenid()
  241. const code = getParameterByName('code')
  242. const result = await userRequest.userinfo({ ...( openid ? { openid } : { code }) })
  243. // const result ={
  244. // "code": 0,
  245. // "message": "获取成功",
  246. // "data": {
  247. // "id": "1",
  248. // "openid": "oOpc26KiZFBKIm7SB8knFGvov1qg",
  249. // "mobile": "",
  250. // "gender": "0",
  251. // "nickname": "雪寒",
  252. // "avatar": "",
  253. // "subscribe_time": "2022-12-21 15:52:14",
  254. // "addr": "\/\/",
  255. // "status": "1",
  256. // "is_show": ["1", "2", "4"],
  257. // "companyArr": [{
  258. // "companyNo": "GS2302231125079621",
  259. // "companyName": "北京百辰荣达国际科贸有限公司",
  260. // "info": [1,2]
  261. // }, {
  262. // "companyNo": "GS2302231323386950",
  263. // "companyName": "北京泓源广诚国际商贸有限公司",
  264. // "info": [1,2]
  265. // }, {
  266. // "companyNo": "GS2304031312553746",
  267. // "companyName": "北京锦兴弘昌科技有限公司",
  268. // "info": [1, 2]
  269. // }, {
  270. // "companyNo": "GS2302231124114965",
  271. // "companyName": "北京普润心堂商贸有限公司",
  272. // "info": [1, 2]
  273. // }, {
  274. // "companyNo": "GS2203161855277894",
  275. // "companyName": "北京万宇恒通国际科贸有限公司",
  276. // "info": [1, 2]
  277. // }],
  278. // "addtime": "2023-04-10 18:11:07",
  279. // "updatetime": "2023-05-09 16:22:33"
  280. // }
  281. // }
  282. this.state.loading = false
  283. switch(Number(result.code)){
  284. case 0:
  285. this.isShow = (result.data.is_show || []).includes(4) || (result.data.is_show || []).includes('4')
  286. this.companies = result.data.companyArr.map(item => ({ companyNo: item.companyNo, companyName: item.companyName }))
  287. this.monthCompanyNo = this.companies[0].companyNo
  288. this.requestData()
  289. break
  290. default:
  291. this.state.error = true
  292. this.state.message = result.message
  293. openid && removeOpenid()
  294. break
  295. }
  296. },
  297. login(){
  298. const redirect_url = encodeURIComponent('http://stat.caixiao365.com/accountsReceivable')
  299. var state = 'wx_' + Math.random().toString(36).substr(2, 15)
  300. const scope = 'snsapi_userinfo'
  301. const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.appId}&redirect_uri=${redirect_url}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`
  302. window.location.href = url
  303. },
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. .new-report {
  309. width: calc(100vw - 20px);
  310. height: 100vh;
  311. left: 0px;
  312. position: fixed;
  313. overflow: auto;
  314. padding: 10px;
  315. .title {
  316. font-size: 14px;
  317. margin: 0px;
  318. }
  319. /deep/.el-input__prefix{
  320. height: auto !important;
  321. }
  322. }
  323. .main-title{
  324. display: flex;
  325. justify-content: space-between;
  326. margin-bottom: 10px;
  327. margin-top: 10px;
  328. }
  329. </style>