supplier.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <div v-loading="loading">
  3. <div class="search clear" style="align-items: center;">
  4. <span style="font-size: 15px;">结算单E企购-月度完成情况</span>
  5. <div style="float:right">
  6. <el-date-picker
  7. class="fr picker no-padding"
  8. v-model="daytime"
  9. style="width:95px"
  10. value-format="yyyy-MM-dd"
  11. :editable="false"
  12. :disabled="isEmpty"
  13. :clearable="false"
  14. :size="'small'"
  15. format="yyyy-MM-dd"
  16. type="date"
  17. align="right"
  18. placeholder="选择日期"
  19. :picker-options="{ disabledDate: time => time.getTime() > Date.now() }"
  20. @change="requestData"
  21. />
  22. </div>
  23. </div>
  24. <el-row style="margin-top:10px;margin-top:10px" v-if="!isEmpty">
  25. <el-table
  26. border
  27. size="mini"
  28. :data="[...totalAmount, ...selfSupport.companyArr, ...otherSupport.companyAmount]"
  29. :header-cell-class-name="setHeaderClassName"
  30. :cell-class-name="setCellClassName"
  31. row-key="companyNo"
  32. :load="load"
  33. lazy
  34. >
  35. <el-table-column type="" fixed="left" label="" prop="order_type" align="center" width="120px">
  36. <template slot-scope="scope">
  37. {{ scope.row.order_type }}
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="公司" prop="companyName" align="center" width="120px">
  41. <template slot-scope="scope">
  42. <span v-if="scope.row.companyName.indexOf('合计-') === -1">
  43. {{ mapCompany2[scope.row.companyName] || scope.row.companyName }}
  44. </span>
  45. <span v-else>
  46. 元隆雅图
  47. </span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="当日营业收入" align="center" width="95px">
  51. <template slot-scope="scope">
  52. {{
  53. isAmountProp(scope.row.companyName)
  54. ? unit2TenThousand(calcAmount('sale_total', scope.row.companyNo), isTenThound)
  55. : unit2TenThousand(scope.row.sale_total, isTenThound)
  56. }}
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="营收目标" align="center" min-width="95px">
  60. <template slot-scope="scope">
  61. {{
  62. isAmountProp(scope.row.companyName)
  63. ? unit2TenThousand(calcAmount('total_tips',scope.row.companyNo), isTenThound)
  64. : unit2TenThousand(scope.row.total_tips, isTenThound)
  65. }}
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="营业收入(净)" align="center" min-width="115px">
  69. <template slot-scope="scope">
  70. <div
  71. style="display:flex;justify-content:center"
  72. :style="`${
  73. isAmountProp(scope.row.companyName)
  74. ? getTotalValueStyle(scope.row, 'msale_total')
  75. : getCurrentValueStyle(scope.row.msale_total, scope.row.total_tips)
  76. }`"
  77. >
  78. {{
  79. isAmountProp(scope.row.companyName)
  80. ? unit2TenThousand(calcAmount('msale_total', scope.row.companyNo), isTenThound)
  81. : unit2TenThousand(scope.row.msale_total, isTenThound)
  82. }}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="营收完成%" align="center" min-width="85px">
  87. <template slot-scope="scope">
  88. <div :style="`${isAmountProp(scope.row.companyName) ? getTotalRateStyle(scope.row,'completion_rate') : getCurrentRateStyle(scope.row.completion_rate)}`">
  89. {{
  90. isAmountProp(scope.row.companyName)
  91. ? calcAmountCompletionRate(scope.row.companyNo)
  92. : isLineRete((String(scope.row.completion_rate) === 'NaN' || Math.abs(scope.row.completion_rate) === Infinity ? 0 : scope.row.completion_rate))
  93. }}
  94. </div>
  95. </template>
  96. </el-table-column>
  97. <template v-if="costField">
  98. <el-table-column label="毛利目标" align="center" min-width="90px">
  99. <template slot-scope="scope">
  100. {{
  101. costField
  102. ? isAmountProp(scope.row.companyName) ? unit2TenThousand(calcAmount('cost_tips',scope.row.companyNo), isTenThound) : unit2TenThousand(scope.row.cost_tips, isTenThound)
  103. : '***'
  104. }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="毛利完成" align="center" min-width="90px">
  108. <template slot-scope="scope">
  109. <div :style="`${isAmountProp(scope.row.companyName) ? getTotalValueStyle(scope.row,'gross_completion', true) : getCurrentValueStyle(scope.row.gross_completion, scope.row.cost_tips)}`">
  110. {{ costField
  111. ? isAmountProp(scope.row.companyName) ? unit2TenThousand(calcAmount('gross_completion', scope.row.companyNo), isTenThound) : unit2TenThousand(scope.row.gross_completion, isTenThound)
  112. : '***'
  113. }}
  114. </div>
  115. </template>
  116. </el-table-column>
  117. </template>
  118. <el-table-column label="毛利完成%" align="center" min-width="85px">
  119. <template slot-scope="scope">
  120. <div :style="isAmountProp(scope.row.companyName) ? getTotalRateStyle(scope.row, 'gross_completion_rate') : getCurrentRateStyle(scope.row.gross_completion_rate)">
  121. {{ isAmountProp(scope.row.companyName) ? calcAmountGrossCompletionRate(scope.row.companyNo) : scope.row.gross_completion_rate === '-' ? '-' : scope.row.gross_completion_rate + '%' }}
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <template v-if="costField">
  126. <el-table-column label="成本合计" align="center" min-width="125px">
  127. <template slot-scope="scope">
  128. <div style="display:flex;justify-content:center" v-if="costField">
  129. {{
  130. isAmountProp(scope.row.companyName)
  131. ? unit2TenThousand(calcAmount('mcost_total', scope.row.companyNo), isTenThound)
  132. : unit2TenThousand(scope.row.mcost_total, isTenThound)
  133. }}
  134. </div>
  135. <p v-else>***</p>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="实际毛利率" align="center" width="85px">
  139. <template slot-scope="scope">
  140. {{ costField
  141. ? isAmountProp(scope.row.companyName) ? calcAmountRealRate(scope.row.companyNo) : unit2TenThousand(scope.row.gross_sale_completion_rate) + "%"
  142. : '***'
  143. }}
  144. </template>
  145. </el-table-column>
  146. </template>
  147. </el-table>
  148. </el-row>
  149. <template v-else>
  150. <div style="text-align:center;line-height:60px;user-select:none">当前账号没有访问权限</div>
  151. </template>
  152. <!-- -->
  153. </div>
  154. </template>
  155. <script>
  156. import { addition, unit2TenThousand, subtraction, multiplication, division } from "../newReport/src/_utils";
  157. import asyncRequest from "@/api/newResults";
  158. import { mapCompany2 } from "./mapCompany";
  159. import { amountData } from "./calc"
  160. import dayjs from "dayjs"
  161. export default {
  162. props: ['companies', 'costField', 'isTenThound'],
  163. data() {
  164. return {
  165. lastSupportCompany: '',
  166. totalAmount:[],
  167. selfSupport:{ companyArr: [] },
  168. otherSupport: { companyArr: [], companyAmount: [] },
  169. daytime: "",
  170. loading: false,
  171. tableData: [],
  172. companyNo: "",
  173. plat_cp_companies:[],
  174. cp_companies: [],
  175. isEmpty: false,
  176. mapCompany2,
  177. composeCompanies: ['QS2206011447553544', 'QS2304031312553756', 'QS2203150147012961'],
  178. otherCompanise: [],
  179. notOtherCompanise: ['QS2206011447553544', 'QS2304031312553756', 'QS2203150147012961','QS2203150147013805','QS2203150147015222','QS2206011103304501']
  180. }
  181. },
  182. mounted() {
  183. let hasCompose = false;
  184. const jxIndex = this.companies.findIndex((item) => item.label === "北京锦兴弘昌科技有限公司");
  185. const prIndex = this.companies.findIndex((item) => item.label === "北京普润心堂商贸有限公司");
  186. const zsIndex = this.companies.findIndex((item) => item.label === "北京知事文化产业发展有限公司");
  187. if (jxIndex !== -1 || prIndex !== -1 || zsIndex !== -1) hasCompose = true;
  188. this.cp_companies = this.companies.filter((item) => item.label !== "北京锦兴弘昌科技有限公司" && item.label !== "北京普润心堂商贸有限公司" && item.label !== "北京知事文化产业发展有限公司")
  189. if (hasCompose) this.cp_companies = [...this.cp_companies, { value: "GS2302231124114965", label: "普润&锦兴&知事" }]
  190. this.isEmpty = this.cp_companies.length === 0;
  191. if (this.isEmpty) return;
  192. this.cp_companies = this.cp_companies.map((item, index) => {
  193. let label = '';
  194. if (item.label === '北京万宇恒通国际科贸有限公司') { label = '平台公司: 万宇' }
  195. if (item.label === '北京泰文创供应链管理有限公司') { label = '平台公司: 泰文创' }
  196. if (item.label === '北京元隆雅图文化传播股份有限公司') { label = '预订单E企购' }
  197. if (item.label === '结算单E企购') { label = '结算单E企购' }
  198. if (item.label === "普润&锦兴&知事") { label = `业务公司: 普润&锦兴&知事` }
  199. if (label === '') label = `业务公司: ${mapCompany2[item.label]}`;
  200. return ({ ...item, label })
  201. })
  202. let plat_list = ['所有平台公司','平台公司: 万宇', '平台公司: 泰文创', '预订单E企购', '结算单E企购']
  203. const plat_cp_list = this.cp_companies.map((item) => item.label);
  204. plat_list = plat_list.filter(item => plat_cp_list.includes(item));
  205. this.plat_cp_companies = plat_list.map((item) => this.cp_companies.find((cp_item) => cp_item.label === item));
  206. if(this.plat_cp_companies.length === 4){ this.plat_cp_companies = [{ value: "", label: "所有平台公司" }, ...this.plat_cp_companies] }
  207. this.companyNo = this.plat_cp_companies[0].value;
  208. // this.daytime = "2024-07-31"
  209. this.daytime = this.transformTime();
  210. this.requestData();
  211. },
  212. methods: {
  213. isLineRete(value){
  214. return value === '-' ? '-' : value + '%'
  215. },
  216. calcAmountRealRate(companyNo){
  217. const msale_total = this.calcAmount('msale_total',companyNo)
  218. const gross_completion = this.calcAmount('gross_completion',companyNo)
  219. const value = Number(multiplication(Number(division(gross_completion, msale_total)).toFixed(2), 100)).toFixed(2)
  220. return isNaN(value) ? '0%' : value + '%'
  221. },
  222. calcAmountGrossCompletionRate(companyNo){
  223. if(companyNo === 'selfSupportOrderPR') return '-'
  224. let cost_tips = ''
  225. if(companyNo === 'selfSupportOrderAmount'){
  226. cost_tips = this.selfSupport.cost_tips
  227. } else if(companyNo === 'otherSupportOrderAmount'){
  228. cost_tips = this.otherSupport.cost_tips
  229. }else {
  230. cost_tips = this.calcAmount('cost_tips', companyNo)
  231. }
  232. const gross_completion = this.calcAmount('gross_completion', companyNo)
  233. return Number(multiplication(Number(division(gross_completion, cost_tips)).toFixed(2), 100)).toFixed(2) + '%'
  234. },
  235. getTotalValueStyle(row, prop, isCost = false){
  236. const days = dayjs(this.daytime).daysInMonth();
  237. const total_tips = this.calcAmount(isCost ? 'cost_tips' : 'total_tips', row.companyNo)
  238. const current = this.calcAmount(prop, row.companyNo)
  239. const oneDay = Number(division(total_tips, days)).toFixed(2);
  240. const currentDay = dayjs(this.daytime).date();
  241. const currentTotalTip = Number(multiplication(currentDay, oneDay)).toFixed(2);
  242. console.log(current,currentTotalTip)
  243. return Number(currentTotalTip) > Number(current) ? 'color: red' : '';
  244. },
  245. getTotalRateStyle(row, prop) {
  246. const days = dayjs(this.daytime).daysInMonth();
  247. const oneDay = Number(division(100, days)).toFixed(2);
  248. const currentDay = dayjs(this.daytime).date();
  249. let currentTotalTip = Number(multiplication(currentDay, oneDay))
  250. currentTotalTip = Number(currentTotalTip > 100 ? 100 : currentTotalTip).toFixed(2)
  251. let current = ''
  252. if(prop === 'completion_rate'){
  253. current = this.calcAmountCompletionRate(row.companyNo)
  254. }{
  255. current = this.calcAmountGrossCompletionRate(row.companyNo)
  256. }
  257. if(String(current).indexOf('%')) current = current.replace('%','')
  258. return Number(currentTotalTip) > Number(current) ? 'color:red' : ''
  259. },
  260. getCurrentRateStyle(current) {
  261. const days = dayjs(this.daytime).daysInMonth();
  262. const oneDay = Number(division(100, days)).toFixed(2);
  263. const currentDay = dayjs(this.daytime).date();
  264. const currentTotalTip = Number(multiplication(currentDay, oneDay)).toFixed(2);
  265. return Number(currentTotalTip) > Number(current) ? 'color:red' : ''
  266. },
  267. getCurrentValueStyle(current, total = 0) {
  268. const days = dayjs(this.daytime).daysInMonth();
  269. const oneDay = Number(division(total, days)).toFixed(2);
  270. const currentDay = dayjs(this.daytime).date();
  271. const currentTotalTip = Number(multiplication(currentDay, oneDay)).toFixed(2);
  272. return Number(currentTotalTip) > Number(current) ? 'color: red' : '';
  273. },
  274. calcAmountCompletionRate(companyNo){
  275. const msale_total = this.calcAmount('msale_total', companyNo)
  276. const total_tips = this.calcAmount('total_tips', companyNo)
  277. return Number(multiplication(Number(division(msale_total, total_tips)).toFixed(2), 100)).toFixed(2) + '%'
  278. },
  279. calcAmount(prop, companyNo){
  280. let sourceData = []
  281. if(companyNo === 'totalAmount'){
  282. const selfTotal = this.calcAmount(prop, 'selfSupportOrderAmount')
  283. const otherTotal = this.calcAmount(prop, 'otherSupportOrderAmount')
  284. return Number(addition(selfTotal, otherTotal)).toFixed(2)
  285. }
  286. if(companyNo === 'selfSupportOrderPR') {
  287. sourceData = this.selfSupport.companyArr.find(({companyName}) => companyName === '普润').children
  288. if(prop === 'total_tips' || prop === 'cost_tips'){ return sourceData[0][prop] }
  289. }
  290. if(companyNo === 'otherSupportOrderAmount'){
  291. if(prop === 'total_tips'){
  292. return this.otherSupport.total_tips
  293. }
  294. if(prop === 'cost_tips'){
  295. return this.otherSupport.cost_tips
  296. }
  297. sourceData = this.otherSupport.companyArr
  298. }
  299. if(companyNo === 'selfSupportOrderAmount') {
  300. const children = this.selfSupport.companyArr.find(({companyName}) => companyName === '普润').children
  301. if(prop === 'cost_tips'){
  302. return this.selfSupport.cost_tips
  303. }
  304. if(prop === 'total_tips'){
  305. return this.selfSupport.total_tips
  306. }
  307. sourceData = [...this.selfSupport.companyArr, ...children]
  308. if(prop === 'cost_tips') { return '-' }
  309. }
  310. return sourceData.reduce((prev, current) => {
  311. if(!current) return 0
  312. const value = Number(addition(prev,isNaN(current[prop]) ? 0 : current[prop]))
  313. return value === 0 ? 0 : value.toFixed(2)
  314. }, 0)
  315. },
  316. isAmountProp(companyName){
  317. return companyName === '普润' || companyName === '其他' || companyName === '合计'
  318. },
  319. load(_1,_2,resolve){
  320. const ylBusiness = this.tableData.find(({companyNo}) => companyNo === 'compoeseSupplier')
  321. resolve(ylBusiness ? ylBusiness.children : [])
  322. },
  323. unit2TenThousand,
  324. handleData(data){
  325. let companyArr = []
  326. data.companyArr.forEach(({
  327. supplierName,
  328. supplierNo,
  329. total_tips = '-',
  330. monthinfo,
  331. cost_tips = '-',
  332. dayinfo,
  333. is_sup = '-'
  334. }) => {
  335. total_tips = Number(total_tips) === 0 ? '-' : total_tips
  336. const mapResponseType = { '1': '自营' }
  337. const types = Object.keys(mapResponseType)
  338. let prev_sale_total = 0;
  339. let prev_msale_total = 0;
  340. let prev_cost_total = 0;
  341. let prev_mcost_total = 0;
  342. const item = types.map(type => {
  343. let _monthinfo = (Array.isArray(monthinfo) ? monthinfo : [monthinfo])[0]
  344. let _dayinfo = (Array.isArray(dayinfo) ? dayinfo : [dayinfo])[0]
  345. const defaultMonthInfo = { mcgd_th_total : "0.00", mcgd_total:"0.00", msale_total: "0.00", mth_total: "0.00", type }
  346. const defaultDayinfo = { "sale_total": "0.00", "th_total": "0.00", "type": "1", "cgd_total": "0.00", "cgd_th_total": "0.00", type }
  347. if(!_monthinfo) _monthinfo = defaultMonthInfo
  348. if(!_dayinfo) _dayinfo = defaultDayinfo
  349. /** 月营业收入 = 月销售额 - 月退货额 */
  350. let msale_total = 0;
  351. if('msale_th_total' in _monthinfo){ _monthinfo.mth_total = _monthinfo.msale_th_total }
  352. // if(Number(type) !== 4){
  353. msale_total = subtraction(_monthinfo.msale_total, _monthinfo.mth_total) || 0
  354. // }
  355. /** 日营业收入 = 日销售额 - 日退货额 */
  356. const sale_total = subtraction(_dayinfo.sale_total, _dayinfo.sale_th_total) || 0;
  357. /** 日成本 = 日采购额 - 日退货额 */
  358. const cost_total = subtraction(_dayinfo.cgd_total, _dayinfo.cgd_th_total) || 0;
  359. /** 月成本 = 月采购额 - 月退货额 */
  360. let mcost_total = 0;
  361. // if(Number(type) !== 4){
  362. mcost_total = subtraction(_monthinfo.mcgd_total, _monthinfo.mcgd_th_total) || 0;
  363. // }else{
  364. // mcost_total = Number(_monthinfo.mcgd_total || 0).toFixed(2);
  365. // }
  366. prev_sale_total = Number(addition(prev_sale_total, sale_total)).toFixed(2);
  367. prev_msale_total = Number(addition(prev_msale_total, msale_total)).toFixed(2);
  368. prev_cost_total = Number(addition(prev_cost_total, cost_total)).toFixed(2);
  369. prev_mcost_total = Number(addition(prev_mcost_total, mcost_total)).toFixed(2);
  370. return {
  371. type: mapResponseType[type],
  372. dayinfo: { ..._dayinfo, sale_total },
  373. monthinfo: { ...monthinfo, msale_total, mcost_total }
  374. }
  375. })
  376. const gross_completion = Number(subtraction(prev_msale_total, prev_mcost_total)).toFixed(2) //当月毛利完成 = 月营收 - 月成本
  377. companyArr = [
  378. ...companyArr,
  379. {
  380. is_sup,
  381. companyNo: supplierNo,
  382. companyName: supplierName, // 公司名称
  383. cost_tips, // 当月成本指标
  384. total_tips, // 当月营收目标
  385. info: item[0], // 直营..渠道 销售
  386. sale_total: prev_sale_total, // 当日营业收入
  387. cost_total: prev_cost_total, // 当日成本总额
  388. msale_total: prev_msale_total, // 当月营业收入
  389. mcost_total: prev_mcost_total,// 当月成本总额
  390. gross_completion, //当月毛利完成 = 月营收 - 月成本
  391. completion_rate: total_tips === '-' ? '-' : multiplication(Number(division(prev_msale_total, total_tips)).toFixed(2), 100).toFixed(2), // 当月应收完成率
  392. gross_completion_rate: cost_tips === '-' ? '-' :Number(cost_tips) === 0 ? 0 : multiplication(division(gross_completion, cost_tips) || 0, 100).toFixed(2), // 当月毛利完成率
  393. gross_sale_completion_rate: Number(multiplication(Number(division(gross_completion, prev_msale_total)).toFixed(2), 100)).toFixed(2), // 本月毛利率 = 当月毛利完成 / 当月营业收入
  394. }
  395. ]
  396. })
  397. return companyArr
  398. },
  399. setCellClassName({ column, row, columnIndex }) {
  400. const { label } = column;
  401. let base = ''
  402. if(
  403. (columnIndex === 0 && (row.order_type === '自营订单' || row.order_type === undefined)) &&
  404. row.companyName !== this.lastSupportCompany
  405. ) {
  406. base += 'no-border-bottom '
  407. }
  408. if(row.companyName === "北京万宇恒通国际科贸有限公司") {
  409. base += 'font-bold '
  410. }
  411. if (label === "营收目标") {
  412. base += "bg__success"
  413. return base
  414. }
  415. if ((label.indexOf('营业') !== -1 || label.indexOf('营收') !== -1) && label !== '当日营业收入') {
  416. base += "bg__success_1"
  417. return base;
  418. }
  419. if (label === "毛利目标") {
  420. base += "bg__primary"
  421. return base
  422. }
  423. if (label.indexOf('毛利') !== -1) {
  424. base += "bg__primary_1"
  425. return base;
  426. }
  427. if (label.indexOf('成本') !== -1) {
  428. base += "bg__warning_1"
  429. return base;
  430. }
  431. return base
  432. },
  433. setHeaderClassName({ column }) {
  434. const { label } = column;
  435. if (label === "营收目标") { return "bg__success" }
  436. if ((label.indexOf('营业') !== -1 || label.indexOf('营收') !== -1) && label !== '当日营业收入'){
  437. return "bg__success_1"
  438. }
  439. if (label === "毛利目标"){ return "bg__primary" }
  440. if (label.indexOf('毛利') !== -1) { return "bg__primary_1" }
  441. if (label.indexOf('成本') !== -1) { return "bg__warning_1" }
  442. },
  443. transformTime() {
  444. let time = new Date();
  445. let y = time.getFullYear();
  446. let M = time.getMonth() + 1;
  447. let d = time.getDate();
  448. return y + "-" + (M < 10 ? "0" + M : M) + "-" + (d < 10 ? "0" + d : d);
  449. },
  450. async requestData() {
  451. this.loading = true;
  452. this.tableData = [];
  453. const res = await asyncRequest.supplier({ daytime: this.daytime });
  454. if (res.code === 1 && res.data) {
  455. let { '2': selfSupport, '3': otherSupport } = JSON.parse(JSON.stringify(res.data))
  456. console.log(JSON.parse(JSON.stringify(selfSupport)))
  457. selfSupport.companyArr = this.handleData(selfSupport)
  458. otherSupport.companyArr = this.handleData(otherSupport)
  459. this.otherSupport = otherSupport
  460. this.selfSupport = selfSupport
  461. let children = this.selfSupport.companyArr.filter(({companyNo}) => this.composeCompanies.includes(companyNo))
  462. const companies = ['北京普润心堂商贸有限公司', '北京锦兴弘昌科技有限公司', '北京知事文化产业发展有限公司']
  463. children = companies.map(companyName => {
  464. return children.find(item => item.companyName === companyName)
  465. }).filter(item => item !== undefined)
  466. this.selfSupport.companyArr = this.selfSupport.companyArr.filter(({companyNo}) => !this.composeCompanies.includes(companyNo))
  467. this.selfSupport.companyArr = [
  468. {
  469. ...amountData,
  470. companyNo: 'selfSupportOrderAmount',
  471. companyName: '合计'
  472. },
  473. ...(children.length === 0? [] : [{
  474. ...amountData,
  475. companyNo: 'selfSupportOrderPR',
  476. companyName: '普润',
  477. children
  478. }]),
  479. ...this.selfSupport.companyArr
  480. ]
  481. this.otherSupport.companyAmount = [
  482. {
  483. ...amountData,
  484. order_type: '地推订单',
  485. companyName: '合计',
  486. companyNo: 'otherSupportOrderAmount'
  487. }
  488. ]
  489. this.totalAmount = [{
  490. ...amountData,
  491. companyNo: 'totalAmount',
  492. order_type: '结算单E企购',
  493. companyName: '合计'
  494. }]
  495. const zrIndex = this.selfSupport.companyArr.findIndex(({companyNo}) => companyNo === 'QS2206011103304501')
  496. const hyIndex = this.selfSupport.companyArr.findIndex(({companyNo}) => companyNo === 'QS2203150147015222')
  497. if(zrIndex !== -1 && hyIndex !== -1){
  498. const temp = this.selfSupport.companyArr[zrIndex]
  499. this.selfSupport.companyArr[zrIndex] = this.selfSupport.companyArr[hyIndex]
  500. this.selfSupport.companyArr[hyIndex] = temp
  501. }
  502. console.log(this.selfSupport.companyArr)
  503. if(this.selfSupport.companyArr.length === 1){
  504. this.selfSupport.companyArr[0].order_type = '自营订单'
  505. }else{
  506. this.lastSupportCompany = this.selfSupport.companyArr[this.selfSupport.companyArr.length -1].companyName
  507. const middle = Math.floor(this.selfSupport.companyArr.length / 2)
  508. this.selfSupport.companyArr[middle].order_type = '自营订单'
  509. }
  510. // this.otherCompanise = sourceData.filter(({is_sup}) => is_sup === 1)
  511. // sourceData = sourceData.filter(({companyNo}) => !this.composeCompanies.includes(companyNo) && this.notOtherCompanise.includes(companyNo))
  512. // , hasChildren: true, children
  513. // this.tableData = sourceData
  514. } else {
  515. this.tableData = [];
  516. }
  517. this.loading = false;
  518. }
  519. }
  520. }
  521. </script>
  522. <style lang="scss" scoped>
  523. .new-results {
  524. .search {
  525. height: 36px;
  526. padding: 0px 10px;
  527. margin-top: 10px;
  528. flex-wrap: wrap;
  529. }
  530. }
  531. .table-size {
  532. display: flex;
  533. width: 200px;
  534. border: 1px solid #ebeef5;
  535. flex-direction: column;
  536. p {
  537. flex: 1;
  538. border-bottom: 1px solid #ebeef5;
  539. padding: 5px 10px;
  540. margin: 0px;
  541. &:last-child {
  542. border: none;
  543. }
  544. }
  545. }
  546. </style>