purchaseListDtl.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div>
  3. <header>
  4. <h2>{{dtl.name}}</h2>
  5. <Button @click="$router.push('purchaseList')">返回</Button>
  6. </header>
  7. <div class="total-warp">
  8. <ul style="width:72%">
  9. <li>
  10. {{dtl.MaterialTypeCount}}</br>
  11. <span>采购物料数</span>
  12. </li>
  13. <li>
  14. {{dtl.sumMoney}}</br>
  15. <span>采购总额</span>
  16. </li>
  17. <li>
  18. {{dtl.lastYearMoney}}</br>
  19. <span>去年采购额</span>
  20. </li>
  21. <li>
  22. {{dtl.yearMoney}}</br>
  23. <span>今年采购额</span>
  24. </li>
  25. <li>
  26. {{dtl.lastMonthMoney}}</br>
  27. <span>上月采购额</span>
  28. </li>
  29. <li>
  30. {{dtl.monthMoney}}</br>
  31. <span>本月采购额</span>
  32. </li>
  33. </ul>
  34. <ul style="width:26%">
  35. <li style="width:50%">
  36. {{dtl.BackCount}}</br>
  37. <span>退货次数</span>
  38. </li>
  39. <li style="width:50%">
  40. {{dtl.warningTypeCount == -1 ? 0 : dtl.warningTypeCount}}</br>
  41. <span>问题记录</span>
  42. </li>
  43. </ul>
  44. </div>
  45. <h3>采购物料分析(在该供应商采购物料种类共计<span>{{data1.length}}</span>款)</h3>
  46. <Table :columns="columns1" :data="data1"></Table>
  47. <Page
  48. style="margin:10px auto 0;text-align: center;"
  49. :total="req1.total"
  50. :current="req1.pageNum"
  51. :page-size="5"
  52. @on-change="(num)=>pageChange(num,'getSpmAnalyse','req1')"
  53. />
  54. <h3>
  55. 月度采购分析
  56. <DatePicker format="yyyy" type="year" v-model="req2.date" @on-change="selectDate" placeholder="请选择年份" style="width: 200px;float: right;"></DatePicker>
  57. </h3>
  58. <Table :columns="columns2" :data="data2"></Table>
  59. <h3>
  60. 单价调整记录
  61. </h3>
  62. <Table :columns="columns3" :data="data3"></Table>
  63. <Page
  64. style="margin:10px auto 0;text-align: center;"
  65. :total="req1.total"
  66. :current="req1.pageNum"
  67. :page-size="5"
  68. @on-change="(num)=>pageChange(num,'getSuList','req3')"
  69. />
  70. <h3>
  71. 退货记录(共计退货面料<span>{{sumTotal.count}}</span>件,<span>{{sumTotal.sumMoney}}</span>元)
  72. <DatePicker format="yyyy" type="year" v-model="req2.date" @on-change="selectDate" placeholder="请选择年份" style="width: 200px;float: right;"></DatePicker>
  73. </h3>
  74. <Table :columns="columns4" :data="data4"></Table>
  75. <h3>
  76. 问题反馈(共计反馈问题<span>{{data5[0].total}}</span>次)
  77. </h3>
  78. <Table :columns="columns5" :data="data5"></Table>
  79. </div>
  80. </template>
  81. <script>
  82. import axios from 'axios'
  83. export default {
  84. data(){
  85. return {
  86. dtl:{
  87. BackCount:null,
  88. MaterialTypeCount:null,
  89. },
  90. columns1:[
  91. {
  92. title: '序号',
  93. type: 'index',
  94. width: 60,
  95. align: 'center'
  96. },
  97. {
  98. title: '物料类型',
  99. key: 'categoryName'
  100. },
  101. {
  102. title: '面料名称',
  103. key: 'materialName',
  104. width:300
  105. },
  106. {
  107. title: '采购总额',
  108. key: 'sumMoney'
  109. },
  110. {
  111. title: '采购占比',
  112. key: 'purProportion',
  113. render:(h,p)=>{
  114. console.log(p.row.purProportion)
  115. return h('span',{},
  116. p.row.purProportion * 1000 /10 + '%'
  117. )
  118. }
  119. },
  120. {
  121. title: '上个月采购额',
  122. key: 'lastMonthMoney'
  123. },
  124. {
  125. title: '本月采购额',
  126. key: 'monthMoney'
  127. },
  128. ],
  129. data1:[],
  130. columns2:[],
  131. data2:[],
  132. data3:[],
  133. columns4:[],
  134. columns5:[],
  135. data5:[
  136. {
  137. name:"数量",
  138. total:0
  139. }
  140. ],
  141. data4:[],
  142. columns3:[
  143. {
  144. title: '序号',
  145. type: 'index',
  146. width: 60,
  147. align: 'center'
  148. },
  149. {
  150. title: '面料名称',
  151. key: 'materialName'
  152. },
  153. {
  154. title: '调整时间',
  155. key: 'createdTime'
  156. },
  157. {
  158. title: '原单价',
  159. key: 'oldPrice'
  160. },
  161. {
  162. title: '调整后单价',
  163. key: 'newPrice',
  164. render:(h,p)=>{
  165. return h('span',{
  166. style:{
  167. color:(p.row.newPrice > p.row.oldPrice) ? 'red' : '#008012'
  168. },
  169. },
  170. p.row.newPrice
  171. )
  172. }
  173. },
  174. ],
  175. req3:{
  176. pageNum:1,
  177. pageSize:5,
  178. total:0,
  179. },
  180. req2:{
  181. date:'2022',
  182. },
  183. req1:{
  184. pageNum:1,
  185. pageSize:5,
  186. total:0,
  187. },
  188. sumTotal:{
  189. count:0,
  190. sumMoney:0,
  191. },
  192. supplierProblemDict:{
  193. 1:"短少",
  194. 2:'抽纱',
  195. 3: "褶皱",
  196. 4: "脏污",
  197. 5: "破洞",
  198. 6: "缩水"
  199. },
  200. }
  201. },
  202. methods:{
  203. selectDate(e){
  204. this.req2.date = e
  205. this.getMonthSum()
  206. },
  207. pageChange(num,fnName,reqName){
  208. const v = this
  209. v[reqName].pageNum = num
  210. v[fnName]()
  211. },
  212. getCount(){
  213. const v = this
  214. axios
  215. .get('/cloudApi/supplier/su/count?id=' + v.dtl.id, {})
  216. .then((res) => {
  217. this.$Spin.hide()
  218. this.dtl.BackCount = res.data.data.BackCount
  219. this.dtl.MaterialTypeCount = res.data.data.MaterialTypeCount
  220. })
  221. },
  222. //问题统计
  223. getStatisticsProblem(){
  224. const v = this
  225. axios
  226. .get('/cloudApi/supplierProblem/statisticsProblem?id=' + v.dtl.id, {})
  227. .then((res) => {
  228. console.log(res)
  229. const columnsCopy = [{
  230. title: ' ',
  231. key: 'name'
  232. },{
  233. title: '合计',
  234. key: 'total'
  235. }]
  236. const dataCopy = [{
  237. name:"数量",
  238. total:0
  239. }]
  240. for (const key in res.data.data) {
  241. columnsCopy.push({
  242. title: v.supplierProblemDict[key],
  243. key: key
  244. })
  245. dataCopy[0][key] = res.data.data[key]
  246. dataCopy[0].total += res.data.data[key]
  247. }
  248. v.columns5 = columnsCopy
  249. v.data5 = dataCopy
  250. })
  251. },
  252. //采购物料分析
  253. getSpmAnalyse(){
  254. this.$Spin.show()
  255. axios
  256. .post('/cloudApi/supplier/su/spmAnalyse', { ...this.req1,id:this.dtl.id })
  257. .then((res) => {
  258. this.$Spin.hide()
  259. this.data1 = res.data.data
  260. })
  261. axios
  262. .post('/cloudApi/supplier/su/spmAnalyse/count', { ...this.req1,id:this.dtl.id })
  263. .then((res) => {
  264. this.req1.total = res.data.data
  265. })
  266. },
  267. //月度采购分析
  268. getMonthSum(e){
  269. const v = this
  270. axios.get('/cloudApi/supplier/purchase/month/sum?id=' + v.dtl.id +"&date=" + v.req2.date, {})
  271. .then((res) => {
  272. this.$Spin.hide()
  273. const columns2Copy = [
  274. {
  275. title: '时间',
  276. key: 'name'
  277. }
  278. ]
  279. const data2Copy = [
  280. {
  281. name:"采购额"
  282. },
  283. {
  284. name:'占公司比例'
  285. },
  286. ]
  287. for (let i = 0; i < res.data.data.length; i++) {
  288. const element = res.data.data[i];
  289. columns2Copy.push({
  290. title: element.createdTime.slice(0,7),
  291. key: element.createdTime
  292. })
  293. data2Copy[0][element.createdTime] = element.money * 1
  294. data2Copy[1][element.createdTime] = element.purProportion * 1000 / 10 + '%'
  295. }
  296. v.columns2 = columns2Copy
  297. v.data2 = data2Copy
  298. })
  299. },
  300. //单价调整记录
  301. getSuList(){
  302. const v = this
  303. this.$Spin.show()
  304. axios
  305. .post('/cloudApi/supplierPricechange/su/list', { ...this.req3,id:this.dtl.id })
  306. .then((res) => {
  307. this.$Spin.hide()
  308. this.data3 = res.data.data
  309. })
  310. axios
  311. .post('/cloudApi/supplierPricechange/su/list/count', { ...this.req3,id:this.dtl.id })
  312. .then((res) => {
  313. this.req3.total = res.data.data
  314. })
  315. },
  316. //退货记录
  317. getSum(){
  318. const v = this
  319. axios.get('/cloudApi/supplier/back/sum?id=' + v.dtl.id +"&date=" + v.req2.date,{}).then(res=>{
  320. this.sumTotal = res.data.data
  321. })
  322. axios.get('/cloudApi/supplier/month/getSum?id=' + v.dtl.id +"&date=" + v.req2.date, {})
  323. .then((res) => {
  324. this.$Spin.hide()
  325. const columns2Copy = [
  326. {
  327. title: '时间',
  328. key: 'name'
  329. }
  330. ]
  331. const data2Copy = [
  332. {
  333. name:"退货件数"
  334. },
  335. {
  336. name:'退货金额'
  337. },
  338. ]
  339. for (let i = 0; i < res.data.data.length; i++) {
  340. const element = res.data.data[i];
  341. element.createdTime = element.createdTime.slice(0,7)
  342. columns2Copy.push({
  343. title: element.createdTime,
  344. key: element.createdTime
  345. })
  346. data2Copy[0][element.createdTime] = (element.count == -1 ) ? 0 : element.count * 1
  347. data2Copy[1][element.createdTime] = element.sumMoney * 1
  348. }
  349. v.columns4 = columns2Copy
  350. v.data4 = data2Copy
  351. })
  352. },
  353. init(){
  354. this.getCount()
  355. this.getSpmAnalyse()
  356. this.getMonthSum()
  357. this.getSuList()
  358. this.getSum()
  359. this.getStatisticsProblem()
  360. },
  361. },
  362. created(){
  363. console.log(this.$route)
  364. this.$route.query.BackCount = 0
  365. this.$route.query.MaterialTypeCount = 0
  366. this.dtl = this.$route.query
  367. this.init()
  368. },
  369. }
  370. </script>
  371. <style lang="less" scoped>
  372. h2{
  373. font-size: 18px;
  374. margin-bottom:20px;
  375. float: left;
  376. color: #000000;
  377. }
  378. header{
  379. overflow: hidden;
  380. button{
  381. float: right;
  382. }
  383. }
  384. h3{
  385. font-size: 14px;
  386. line-height: 58px;
  387. span{
  388. color: red;
  389. }
  390. }
  391. .total-warp{
  392. display: flex;
  393. justify-content: space-between;
  394. ul{
  395. height: 76px;
  396. border:1px solid #979797;
  397. background: #fff;
  398. li{
  399. float: left;
  400. width: 16.666%;
  401. text-align: center;
  402. line-height: 30px;
  403. list-style: none;
  404. font-size: 14px;
  405. padding:8px 0;
  406. color: #3F3F3F;
  407. font-weight: 600;
  408. span{
  409. color: #6E6E6E;
  410. font-weight: 400;
  411. }
  412. }
  413. }
  414. }
  415. </style>