f9a1ea1c5ae169ea44bb6e8b8764ca9cc6ec0c15.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <div class="app-container">
  3. <!-- <h1>集团</h1> -->
  4. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  5. <el-tab-pane label="库存统计" name="first">
  6. <div class="search">
  7. <el-select v-model="tab.table.getdataListParm.parammaps.pastureid" style="float: left;margin-right: 10px;margin-bottom:10px;width: 150px;" filterable placeholder="牧场" class="filter-item" clearable>
  8. <el-option v-for="item in pastureList" :key="item.pastureid" :label="item.pasturename" :value="item.pastureid" />
  9. </el-select>
  10. <el-date-picker v-model="tab.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="float: left;width: 250px;margin-bottom:10px;" :picker-options="pickerOptions" />
  11. <el-input v-model="tab.table.getdataListParm.parammaps.feedname" class="filter-item" style="float: left;width: 245px;margin-bottom:10px;" placeholder="饲料名称" />
  12. <el-button class="successBorder" style="float: left;margin-left: 10px;margin-bottom:10px;" @click="handleSearch('first')">查询</el-button>
  13. <el-button class="export" style="float: right;margin-right: 10px;margin-bottom:10px;" @click="handleExport(tab1)">导出</el-button>
  14. </div>
  15. <div class="table">
  16. <el-table
  17. :key="tab.table.tableKey"
  18. v-loading="tab.table.listLoading"
  19. element-loading-text="给我一点时间"
  20. :data="tab.table.list"
  21. border
  22. fit
  23. highlight-current-row
  24. style="width: 100%;"
  25. :row-style="rowStyle"
  26. :cell-style="cellStyle"
  27. class="elTable table-fixed"
  28. >
  29. <el-table-column label="饲料名称" min-width="130px" align="center">
  30. <template slot-scope="scope">
  31. <span>{{ scope.row.feedname }}</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="期初" min-width="130px" align="center">
  35. <el-table-column prop="startsum" align="center" label="期初库存(kg)" min-width="120" />
  36. <el-table-column prop="startprice" align="center" label="期初金额(元)" min-width="120" />
  37. </el-table-column>
  38. <el-table-column label="用量" min-width="110px" align="center">
  39. <el-table-column prop="laidsum" align="center" label="入库重量(kg)" min-width="120" />
  40. <el-table-column prop="usesumXT" align="center" label="系统出库重量(kg)" min-width="120" />
  41. <el-table-column prop="usesumRG" align="center" label="人工用料重量(kg)" min-width="120" />
  42. <el-table-column prop="usesumXH" align="center" label="损耗重量(kg)" min-width="120" />
  43. </el-table-column>
  44. <el-table-column label="期末" min-width="130px" align="center">
  45. <el-table-column prop="stopsum" align="center" label="期末库存(kg)" min-width="120" />
  46. <el-table-column prop="stopprice" align="center" label="期末金额(元)" min-width="120" />
  47. </el-table-column>
  48. </el-table>
  49. <pagination v-show="tab.table.total>=0" :total="tab.table.total" :page.sync="tab.table.getdataListParm.offset" :limit.sync="tab.table.getdataListParm.pagecount" @pagination="getTabList" />
  50. </div>
  51. </el-tab-pane>
  52. <el-tab-pane label="用料分析" name="second">
  53. <div class="search">
  54. <el-select v-model="tab2.table.getdataListParm.parammaps.pastureid" style="float: left;margin-right: 10px;margin-bottom:10px;width: 150px;" filterable placeholder="牧场" class="filter-item" clearable>
  55. <el-option v-for="item in pastureList" :key="item.pastureid" :label="item.pasturename" :value="item.pastureid" />
  56. </el-select>
  57. <el-date-picker v-model="tab2.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" :picker-options="pickerOptions" />
  58. <span style="margin-left: 10px;">统计类型:</span>
  59. <el-radio v-model="tab2.radio" label="1" @change="changeRadio2">牲畜类别</el-radio>
  60. <el-radio v-model="tab2.radio" label="2" @change="changeRadio2">栏舍名称</el-radio>
  61. <el-radio v-model="tab2.radio" label="3" @change="changeRadio2">日期</el-radio>
  62. <el-radio v-model="tab2.radio" label="4" @change="changeRadio2">TMR设备编号</el-radio>
  63. <el-radio v-model="tab2.radio" label="5" @change="changeRadio2">班次</el-radio>
  64. <el-radio v-model="tab2.radio" label="6" @change="changeRadio2">车次</el-radio>
  65. <el-input v-if="tab2.isRadio1" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="牲畜类别" />
  66. <el-input v-if="tab2.isRadio2" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="栏舍名称" />
  67. <el-input v-if="tab2.isRadio3" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="日期" />
  68. <el-input v-if="tab2.isRadio4" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="TMR设备编号" />
  69. <el-input v-if="tab2.isRadio5" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="班次" />
  70. <el-input v-if="tab2.isRadio6" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="车次" />
  71. <el-button class="successBorder" @click="handleSearch('second')">查询</el-button>
  72. <el-button class="export" style="float: right;margin-right: 5px;" @click="handleExport('tab2')">导出</el-button>
  73. </div>
  74. <el-table
  75. :key="tab2.table.tableKey"
  76. v-loading="tab2.table.listLoading"
  77. element-loading-text="给我一点时间"
  78. :data="tab2.table.list"
  79. border
  80. fit
  81. highlight-current-row
  82. style="width: 100%;"
  83. :row-style="rowStyle"
  84. :cell-style="cellStyle"
  85. class="elTable table-fixed"
  86. >
  87. <el-table-column v-for="item in tab2.table.tableConfig" align="center" :label="item.label" :prop="item.prop">
  88. <el-table-column v-for="item1 in item.children" v-if="item.children || item.children.length>0" align="center" :label="item1.label" :prop="item1.prop">
  89. <el-table-column v-for="item2 in item1.children" v-if="item1.children || item1.children.length>0" :label="item2.label" :prop="item2.prop" />
  90. </el-table-column>
  91. </el-table-column>
  92. </el-table>
  93. </el-tab-pane>
  94. <el-tab-pane label="价格分析" name="third">
  95. <div class="search">
  96. <el-select v-model="tab3.table.getdataListParm.parammaps.pastureid" style="float: left;margin-right: 10px;margin-bottom:10px;width: 150px;" filterable placeholder="牧场" class="filter-item" clearable>
  97. <el-option v-for="item in pastureList" :key="item.pastureid" :label="item.pasturename" :value="item.pastureid" />
  98. </el-select>
  99. <el-date-picker v-model="tab3.table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" :picker-options="pickerOptions" />
  100. <span style="margin-left: 10px;">统计类型:</span>
  101. <el-radio v-model="tab3.radio" label="1" @change="changeRadio3">牲畜类别</el-radio>
  102. <el-radio v-model="tab3.radio" label="2" @change="changeRadio3">栏舍名称</el-radio>
  103. <el-radio v-model="tab3.radio" label="3" @change="changeRadio3">日期</el-radio>
  104. <el-radio v-model="tab3.radio" label="4" @change="changeRadio3">TMR设备编号</el-radio>
  105. <el-input v-if="tab3.isRadio1" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="牲畜类别" />
  106. <el-input v-if="tab3.isRadio2" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="栏舍名称" />
  107. <el-input v-if="tab3.isRadio3" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="日期" />
  108. <el-input v-if="tab3.isRadio4" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="TMR设备编号" />
  109. <el-button class="successBorder" @click="handleSearch('third')">查询</el-button>
  110. <el-button class="export" style="float: right;margin-right: 5px;" @click="handleExport('tab3')">导出</el-button>
  111. </div>
  112. <el-table
  113. :key="tab3.table.tableKey"
  114. v-loading="tab3.table.listLoading"
  115. element-loading-text="给我一点时间"
  116. :data="tab3.table.list"
  117. border
  118. fit
  119. highlight-current-row
  120. style="width: 100%;"
  121. :row-style="rowStyle"
  122. :cell-style="cellStyle"
  123. class="elTable table-fixed"
  124. >
  125. <el-table-column v-for="item in tab3.table.tableConfig" align="center" :label="item.label" :prop="item.prop">
  126. <el-table-column v-for="item1 in item.children" v-if="item.children || item.children.length>0" align="center" :label="item1.label" :prop="item1.prop">
  127. <el-table-column v-for="item2 in item1.children" v-if="item1.children || item1.children.length>0" :label="item2.label" :prop="item2.prop" />
  128. </el-table-column>
  129. </el-table-column>
  130. </el-table>
  131. </el-tab-pane>
  132. </el-tabs>
  133. </div>
  134. </div>
  135. </template>
  136. <script>
  137. import { GetDataByName, GetDataByNames, GetReportform } from '@/api/common'
  138. import Cookies from 'js-cookie'
  139. import { parseTime } from '@/utils/index.js'
  140. import Pagination from '@/components/Pagination'
  141. export default {
  142. name: 'GroupInventoryManagement',
  143. components: { Pagination },
  144. data() {
  145. return {
  146. pickerMinDate: '',
  147. pickerOptions: {
  148. onPick: ({ maxDate, minDate }) => {
  149. this.pickerMinDate = minDate.getTime()
  150. if (maxDate) {
  151. this.pickerMinDate = ''
  152. }
  153. },
  154. // 限制不能选择今天之后的日期
  155. disabledDate: (time) => {
  156. if (this.pickerMinDate !== '') {
  157. const one = 31 * 24 * 3600 * 1000
  158. const minTime = this.pickerMinDate - one
  159. let maxTime = this.pickerMinDate + one
  160. if (maxTime > new Date()) {
  161. maxTime = new Date()
  162. }
  163. return time.getTime() < minTime || time.getTime() > maxTime
  164. }
  165. return time.getTime() > Date.now()
  166. }
  167. },
  168. requestParams: [
  169. { name: 'getPastureListJT', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), pasturename: '' }}
  170. ],
  171. pastureList: [], // 牧场
  172. fileComment: [{ 'label': '商务文件评分', 'children': [{ 'label': '1' }, { 'label': '2' }, { 'label': '管理员' }] }],
  173. activeName: 'first',
  174. tab: {
  175. chartDate: [],
  176. table: {
  177. getdataListParm: {
  178. name: 'getfsStaticlist',
  179. page: 1,
  180. offset: 1,
  181. pagecount: 10,
  182. returntype: 'Map',
  183. parammaps: {
  184. pastureid: '',
  185. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  186. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  187. inputDatetime: [new Date(), new Date()],
  188. feedname: ''
  189. }
  190. },
  191. tableKey: 1,
  192. list: [],
  193. total: 0,
  194. listLoading: true
  195. }
  196. },
  197. tab2: {
  198. chartDate: [],
  199. table: {
  200. getdataListParm: {
  201. name: 'getMaterialAnalysisSC',
  202. page: 1,
  203. offset: 1,
  204. pagecount: '',
  205. returntype: 'Map',
  206. parammaps: {
  207. pastureid: '',
  208. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  209. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  210. inputDatetime: [new Date(), new Date()],
  211. fname: ''
  212. }
  213. },
  214. tableKey: 1,
  215. list: [],
  216. tableConfig: [],
  217. total: 0,
  218. listLoading: true
  219. },
  220. radio: '1',
  221. isRadio1: true,
  222. isRadio2: false,
  223. isRadio3: false,
  224. isRadio4: false,
  225. isRadio5: false,
  226. isRadio6: false
  227. },
  228. tab3: {
  229. chartDate: [],
  230. table: {
  231. getdataListParm: {
  232. name: 'getPriceAnalysisSC',
  233. page: 1,
  234. offset: 1,
  235. pagecount: 10,
  236. returntype: 'Map',
  237. parammaps: {
  238. pastureid: '',
  239. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  240. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  241. inputDatetime: [new Date(), new Date()],
  242. fname: ''
  243. }
  244. },
  245. tableKey: 1,
  246. list: [],
  247. tableConfig: [],
  248. total: 0,
  249. listLoading: true
  250. },
  251. radio: '1',
  252. isRadio1: true,
  253. isRadio2: false,
  254. isRadio3: false,
  255. isRadio4: false
  256. },
  257. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  258. cellStyle: { padding: 0 + 'px' }
  259. }
  260. },
  261. created() {
  262. this.getDownList()
  263. this.getTimeFn()
  264. },
  265. methods: {
  266. getDownList() {
  267. GetDataByNames(this.requestParams).then(response => {
  268. this.pastureList = response.data.getPastureListJT.list
  269. this.tab.table.getdataListParm.parammaps.pastureid = response.data.getPastureListJT.list[0].pastureid
  270. this.getTabList()
  271. })
  272. },
  273. getTimeFn() {
  274. const that = this
  275. const end = new Date()
  276. const start = new Date()
  277. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  278. that.tab.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  279. that.tab.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  280. that.tab.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  281. that.tab.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  282. that.tab.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  283. that.tab.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  284. that.tab2.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  285. that.tab2.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  286. that.tab2.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  287. that.tab2.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  288. that.tab2.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  289. that.tab2.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  290. that.tab3.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  291. that.tab3.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  292. that.tab3.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  293. that.tab3.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  294. that.tab3.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  295. that.tab3.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  296. },
  297. handleTabClick() {
  298. if (this.activeName == 'first') {
  299. this.getTabList()
  300. } else if (this.activeName == 'second') {
  301. console.log(this.pastureList)
  302. this.tab2.table.getdataListParm.parammaps.pastureid = this.pastureList[0].pastureid
  303. this.getTab2List()
  304. } else if (this.activeName == 'third') {
  305. this.tab3.table.getdataListParm.parammaps.pastureid = this.pastureList[0].pastureid
  306. this.getTab3List()
  307. }
  308. },
  309. getTabList() {
  310. this.tab.table.listLoading = true
  311. GetDataByName(this.tab.table.getdataListParm).then(response => {
  312. console.log('库存统计table数据', response.data.list)
  313. if (response.data.list !== null) {
  314. this.tab.table.list = response.data.list
  315. this.tab.table.total = response.data.total
  316. } else {
  317. this.tab.table.list = []
  318. }
  319. setTimeout(() => {
  320. this.tab.table.listLoading = false
  321. }, 100)
  322. })
  323. },
  324. handleSearch(item) {
  325. if (item == 'first') {
  326. if (this.tab.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab.table.getdataListParm.parammaps.inputDatetime !== null) {
  327. this.tab.table.getdataListParm.parammaps.startTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  328. this.tab.table.getdataListParm.parammaps.stopTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  329. } else {
  330. this.tab.table.getdataListParm.parammaps.inputDatetime = ''
  331. this.tab.table.getdataListParm.parammaps.startTime = ''
  332. this.tab.table.getdataListParm.parammaps.stopTime = ''
  333. }
  334. this.getTabList()
  335. } else if (item == 'second') {
  336. if (this.tab2.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
  337. this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  338. this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  339. } else {
  340. this.tab2.table.getdataListParm.parammaps.inputDatetime = ''
  341. this.tab2.table.getdataListParm.parammaps.startTime = ''
  342. this.tab2.table.getdataListParm.parammaps.stopTime = ''
  343. }
  344. this.getTab2List()
  345. } else if (item == 'third') {
  346. if (this.tab3.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab3.table.getdataListParm.parammaps.inputDatetime !== null) {
  347. this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  348. this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  349. } else {
  350. this.tab3.table.getdataListParm.parammaps.inputDatetime = ''
  351. this.tab3.table.getdataListParm.parammaps.startTime = ''
  352. this.tab3.table.getdataListParm.parammaps.stopTime = ''
  353. }
  354. this.getTab3List()
  355. }
  356. },
  357. handleExport(item) {
  358. if(item == 'tab1'){
  359. console.log('库存统计导出')
  360. } else if(item == 'tab2'){
  361. console.log('用料分析导出数据',this.tab2.table.list)
  362. console.log('用料分析导出表头',this.tab2.table.tableConfig)
  363. var exportData = []
  364. var exportTitle1 = []; //一级标题
  365. var exportTitle2 = []; //二级标题
  366. for(let i=0;i<this.tab2.table.tableConfig.length;i++){
  367. exportTitle1.push(this.tab2.table.tableConfig[i].label)
  368. for(let j=0;j<this.tab2.table.tableConfig[i].children.length;j++){
  369. exportTitle2.push(this.tab2.table.tableConfig[i].children[j].label)
  370. }
  371. }
  372. console.log('一级标题exportTitle1',exportTitle1)
  373. console.log('二级标题exportTitle2',exportTitle2)
  374. var headerArr = []// 处理一级标题
  375. for(let i=0;i<exportTitle1.length;i++){
  376. if(i>0){
  377. headerArr.push(exportTitle1[i],'','','')
  378. }else{
  379. headerArr.push(exportTitle1[i])
  380. }
  381. }
  382. console.log('一级表头处理后',headerArr)
  383. var valueArr = []; //对应字段
  384. for(let i=0;i<exportTitle2.length;i++){
  385. if(i==0){
  386. valueArr.push('A')
  387. }else{
  388. valueArr.push('a'+[i-1])
  389. }
  390. }
  391. console.log('对应字段valueArr',valueArr)
  392. if(headerArr.length>0){
  393. import('@/vendor/Export3Excel').then((excel) => {
  394. const multiHeader = [
  395. headerArr
  396. ];
  397. const multiHeader2 = [];
  398. const tHeader = exportTitle2;
  399. const filterVal = valueArr;// 表头所对应的字段,这里未填写
  400. const data = this.tab2.table.list.map(v => filterVal.map(j => v[j]));
  401. // const data = [];
  402. // 进行所有表头的单元格合并
  403. // const merges = ['A1:A1', 'B1:E1','F1:J1' ];
  404. const merges = ['A1:A1'];
  405. excel.export_json_to_excel({multiHeader, multiHeader2, header: tHeader, data, filename: '用料分析', merges, });
  406. });
  407. }
  408. } else if(item == 'tab3'){
  409. console.log('价格分析导出')
  410. console.log('价格分析导出数据',this.tab3.table.list)
  411. console.log('价格分析导出表头',this.tab3.table.tableConfig)
  412. var exportData = []
  413. var exportTitle1 = []; //一级标题
  414. var exportTitle2 = []; //二级标题
  415. for(let i=0;i<this.tab3.table.tableConfig.length;i++){
  416. exportTitle1.push(this.tab3.table.tableConfig[i].label)
  417. for(let j=0;j<this.tab3.table.tableConfig[i].children.length;j++){
  418. exportTitle2.push(this.tab3.table.tableConfig[i].children[j].label)
  419. }
  420. }
  421. console.log('一级标题exportTitle1',exportTitle1)
  422. console.log('二级标题exportTitle2',exportTitle2)
  423. var headerArr = []// 处理一级标题
  424. for(let i=0;i<exportTitle1.length;i++){
  425. if(i>0){
  426. headerArr.push(exportTitle1[i],'')
  427. }else{
  428. headerArr.push(exportTitle1[i])
  429. }
  430. }
  431. console.log('一级表头处理后',headerArr)
  432. var valueArr = []; //对应字段
  433. for(let i=0;i<exportTitle2.length;i++){
  434. if(i==0){
  435. valueArr.push('A')
  436. }else{
  437. valueArr.push('a'+[i-1])
  438. }
  439. }
  440. console.log('对应字段valueArr',valueArr)
  441. if(headerArr.length>0){
  442. import('@/vendor/Export3Excel').then((excel) => {
  443. const multiHeader = [
  444. headerArr
  445. ];
  446. const multiHeader2 = [];
  447. const tHeader = exportTitle2;
  448. const filterVal = valueArr;// 表头所对应的字段,这里未填写
  449. const data = this.tab3.table.list.map(v => filterVal.map(j => v[j]));
  450. // const data = [];
  451. // 进行所有表头的单元格合并
  452. // const merges = ['A1:A1', 'B1:E1','F1:J1' ];
  453. const merges = ['A1:A1'];
  454. excel.export_json_to_excel({multiHeader, multiHeader2, header: tHeader, data, filename: '价格分析', merges, });
  455. });
  456. }
  457. }
  458. },
  459. format(jsonData) { //数据处理
  460. let dataList = [];
  461. for(let i = 0; i< jsonData.length; i++) {
  462. let list = [];
  463. list.push(jsonData[i].index);
  464. list.push(jsonData[i].Personel);
  465. list.push(jsonData[i].address);
  466. for (let j = 0; j < jsonData[0]['time'].length; j++) {
  467. list.push(jsonData[i]['time'][j].morning);
  468. list.push(jsonData[i]['time'][j].afternoon);
  469. }
  470. dataList.push(list);
  471. }
  472. return dataList;
  473. },
  474. // 用料分析
  475. getTab2List() {
  476. this.tab2.table.listLoading = true
  477. GetReportform(this.tab2.table.getdataListParm).then(response => {
  478. console.log('库存统计-用料分析', response.data.list)
  479. if (response.data.list !== null) {
  480. this.tab2.table.list = response.data.list.data1
  481. this.tab2.table.tableConfig = response.data.list.data2
  482. this.tab2.table.total = response.data.total
  483. } else {
  484. this.tab2.table.list = []
  485. }
  486. setTimeout(() => {
  487. this.tab2.table.listLoading = false
  488. }, 100)
  489. })
  490. },
  491. changeRadio2() {
  492. console.log(this.tab2.radio)
  493. if (this.tab2.radio == '1') {
  494. this.tab2.isRadio1 = true,
  495. this.tab2.isRadio2 = false,
  496. this.tab2.isRadio3 = false,
  497. this.tab2.isRadio4 = false,
  498. this.tab2.isRadio5 = false,
  499. this.tab2.isRadio6 = false,
  500. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisSC'
  501. this.tab2.table.getdataListParm.offset = 1
  502. this.getTab2List()
  503. } else if (this.tab2.radio == '2') {
  504. this.tab2.isRadio1 = false,
  505. this.tab2.isRadio2 = true,
  506. this.tab2.isRadio3 = false,
  507. this.tab2.isRadio4 = false,
  508. this.tab2.isRadio5 = false,
  509. this.tab2.isRadio6 = false,
  510. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisLS'
  511. this.tab2.table.getdataListParm.offset = 1
  512. this.getTab2List()
  513. } else if (this.tab2.radio == '3') {
  514. this.tab2.isRadio1 = false,
  515. this.tab2.isRadio2 = false,
  516. this.tab2.isRadio3 = true,
  517. this.tab2.isRadio4 = false,
  518. this.tab2.isRadio5 = false,
  519. this.tab2.isRadio6 = false,
  520. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisRQ'
  521. this.tab2.table.getdataListParm.offset = 1
  522. this.getTab2List()
  523. } else if (this.tab2.radio == '4') {
  524. this.tab2.isRadio1 = false,
  525. this.tab2.isRadio2 = false,
  526. this.tab2.isRadio3 = false,
  527. this.tab2.isRadio4 = true,
  528. this.tab2.isRadio5 = false,
  529. this.tab2.isRadio6 = false,
  530. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisTMR'
  531. this.tab2.table.getdataListParm.offset = 1
  532. this.getTab2List()
  533. } else if (this.tab2.radio == '5') {
  534. this.tab2.isRadio1 = false,
  535. this.tab2.isRadio2 = false,
  536. this.tab2.isRadio3 = false,
  537. this.tab2.isRadio4 = false,
  538. this.tab2.isRadio5 = true,
  539. this.tab2.isRadio6 = false,
  540. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisBC'
  541. this.tab2.table.getdataListParm.offset = 1
  542. this.getTab2List()
  543. } else if (this.tab2.radio == '6') {
  544. this.tab2.isRadio1 = false,
  545. this.tab2.isRadio2 = false,
  546. this.tab2.isRadio3 = false,
  547. this.tab2.isRadio4 = false,
  548. this.tab2.isRadio5 = false,
  549. this.tab2.isRadio6 = true,
  550. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisCC'
  551. this.tab2.table.getdataListParm.offset = 1
  552. this.getTab2List()
  553. }
  554. },
  555. // 价格分析
  556. getTab3List() {
  557. this.tab3.table.listLoading = true
  558. GetReportform(this.tab3.table.getdataListParm).then(response => {
  559. console.log('库存统计-价格分析', response.data.list)
  560. if (response.data.list !== null) {
  561. this.tab3.table.list = response.data.list.data1
  562. this.tab3.table.tableConfig = response.data.list.data2
  563. this.tab3.table.total = response.data.total
  564. } else {
  565. this.tab3.table.list = []
  566. }
  567. setTimeout(() => {
  568. this.tab3.table.listLoading = false
  569. }, 100)
  570. })
  571. },
  572. changeRadio3() {
  573. console.log(this.tab3.radio)
  574. if (this.tab3.radio == '1') {
  575. this.tab3.isRadio1 = true,
  576. this.tab3.isRadio2 = false,
  577. this.tab3.isRadio3 = false,
  578. this.tab3.isRadio4 = false,
  579. this.tab3.table.getdataListParm.name = 'getPriceAnalysisSC'
  580. this.tab3.table.getdataListParm.offset = 1
  581. this.getTab3List()
  582. } else if (this.tab3.radio == '2') {
  583. this.tab3.isRadio1 = false,
  584. this.tab3.isRadio2 = true,
  585. this.tab3.isRadio3 = false,
  586. this.tab3.isRadio4 = false,
  587. this.tab3.table.getdataListParm.name = 'getPriceAnalysisLS'
  588. this.tab3.table.getdataListParm.offset = 1
  589. this.getTab3List()
  590. } else if (this.tab3.radio == '3') {
  591. this.tab3.isRadio1 = false,
  592. this.tab3.isRadio2 = false,
  593. this.tab3.isRadio3 = true,
  594. this.tab3.isRadio4 = false,
  595. this.tab3.table.getdataListParm.name = 'getPriceAnalysisRQ'
  596. this.tab3.table.getdataListParm.offset = 1
  597. this.getTab3List()
  598. } else if (this.tab3.radio == '4') {
  599. this.tab3.isRadio1 = false,
  600. this.tab3.isRadio2 = false,
  601. this.tab3.isRadio3 = false,
  602. this.tab3.isRadio4 = true,
  603. this.tab3.table.getdataListParm.name = 'getPriceAnalysisTMR'
  604. this.tab3.table.getdataListParm.offset = 1
  605. this.getTab3List()
  606. }
  607. }
  608. }
  609. }
  610. </script>
  611. <style lang="scss" scoped>
  612. .search{margin-bottom:10px;}
  613. </style>