09b05632f25444bf03836aa6d34f132316eb6826.svn-base 39 KB

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