21a559ff2e80b7953d62ade5758bdf00695f7658.svn-base 39 KB

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