be6698df1fad5e9843d82df248adae37e00923b3.svn-base 27 KB

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