index.vue 39 KB

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