8e8500d0c06d45568399c9ca218b15666b8d15de.svn-base 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="import" style="float: right;margin-bottom: 10px;" @click="handleExport">导出</el-button>
  5. </div>
  6. <div class="table">
  7. <el-table
  8. :key="table.tableKey"
  9. v-loading="table.listLoading"
  10. element-loading-text="给我一点时间"
  11. :data="table.list"
  12. border
  13. fit
  14. highlight-current-row
  15. style="width: 100%;"
  16. :cell-style="cellStyle"
  17. class="elTable table-fixed"
  18. :row-style="rowStyle"
  19. >
  20. <el-table-column label="序号" align="center" type="index" width="50px" />
  21. <!-- <el-table-column label="序号" align="center" type="index" width="50px">
  22. <template slot-scope="scope">
  23. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  24. </template>
  25. </el-table-column> -->
  26. <el-table-column label="饲料名称" min-width="130px" align="center">
  27. <template slot-scope="scope">
  28. <span>{{ scope.row.feedname }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="库存量(kg)" min-width="130px" align="center">
  32. <template slot-scope="scope">
  33. <span>{{ scope.row.stockweight }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="近七天平均计划量(kg)" min-width="110px" align="center">
  37. <template slot-scope="scope">
  38. <span>{{ scope.row.avgweight }}</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="剩余使用天数" min-width="110px" align="center">
  42. <template slot-scope="scope">
  43. <span>{{ scope.row.ldays }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="最近预警日期" min-width="110px" align="center">
  47. <template slot-scope="scope">
  48. <span>{{ scope.row.lastdate }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  52. <template slot-scope="{row}">
  53. <el-button class="miniPrimary" :disabled="isokDisable" @click="handleSee(row)">查看</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </div>
  58. <el-dialog :title="textMap[see.dialogStatus]" :visible.sync="see.dialogFormVisible" :close-on-click-modal="false" width="90%">
  59. <div class="app-see">
  60. <el-form ref="temp" :rules="see.rules" :model="see.temp" label-position="right" label-width="110px" style="width: 100%;margin:0 auto">
  61. <el-row>
  62. <el-col :span="8">
  63. <el-form-item label="饲料名称:" prop="feedname">
  64. <span> {{ see.temp.feedname }}</span>
  65. </el-form-item>
  66. </el-col>
  67. </el-row>
  68. </el-form>
  69. <el-table
  70. :key="see.tableKey"
  71. v-loading="see.listLoading"
  72. element-loading-text="给我一点时间"
  73. :data="see.list"
  74. border
  75. fit
  76. highlight-current-row
  77. style="width: 100%;"
  78. :row-style="rowStyle"
  79. :cell-style="cellStyle"
  80. class="elTable table-fixed"
  81. >
  82. <el-table-column label="序号" align="center" type="index" width="50px">
  83. <template slot-scope="scope">
  84. <span>{{ scope.$index + (see.pageNum-1) * see.pageSize + 1 }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="库存量" min-width="130px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.stockweight }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="近七天平均计划量(kg)" min-width="130px" align="center">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.avgweight }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="剩余使用天数" min-width="110px" align="center">
  98. <template slot-scope="scope">
  99. <span> {{ scope.row.ldays }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="预警日期" min-width="110px" align="center">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.date }}</span>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <pagination v-show="see.total>=0" style="margin-bottom: 50px;" :total="see.total" :page.sync="see.getdataListParm.offset" :limit.sync="see.getdataListParm.pagecount" @pagination="getSeeList" />
  109. <div slot="footer" class="dialog-footer">
  110. <el-button class="cancelClose" @click="see.dialogFormVisible = false; ">关闭</el-button>
  111. </div>
  112. </div>
  113. </el-dialog>
  114. </div>
  115. </template>
  116. <script>
  117. import { GetDataByName } from '@/api/common'
  118. import Pagination from '@/components/Pagination'
  119. import Cookies from 'js-cookie'
  120. import { json2excel } from '@/utils/index.js'
  121. export default {
  122. name: 'Warning',
  123. components: { Pagination },
  124. data() {
  125. return {
  126. table: {
  127. getdataListParm: {
  128. name: 'getFsWarnList',
  129. page: 1,
  130. offset: 1,
  131. pagecount: '',
  132. returntype: 'Map',
  133. parammaps: {
  134. pastureid: Cookies.get('pastureid')
  135. }
  136. },
  137. tableKey: 0,
  138. list: [],
  139. total: 0,
  140. listLoading: true
  141. },
  142. textMap: {
  143. see: '库存预警记录'
  144. },
  145. see: {
  146. dialogFormVisible: false,
  147. dialogStatus: '',
  148. temp: {},
  149. rules: {},
  150. getdataListParm: {
  151. name: 'getFsWarnListdate',
  152. page: 1,
  153. offset: 1,
  154. pagecount: 10,
  155. returntype: 'Map',
  156. parammaps: {
  157. pastureid: Cookies.get('pastureid'),
  158. feedid: ''
  159. }
  160. },
  161. tableKey: 0,
  162. list: [],
  163. total: 0,
  164. listLoading: true
  165. },
  166. download: {
  167. getdataListParm: {
  168. name: 'getFsWarnList',
  169. page: 1,
  170. offset: 1,
  171. pagecount: 0,
  172. returntype: 'Map',
  173. parammaps: {
  174. pastureid: Cookies.get('pastureid')
  175. }
  176. },
  177. list: []
  178. },
  179. isokDisable: false,
  180. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  181. cellStyle: { padding: 0 + 'px' }
  182. }
  183. },
  184. created() {
  185. this.getList()
  186. },
  187. methods: {
  188. getList() {
  189. this.table.listLoading = true
  190. GetDataByName(this.table.getdataListParm).then(response => {
  191. console.log('table数据', response.data.list)
  192. if (response.data.list !== null) {
  193. this.table.list = response.data.list
  194. // this.table.pageNum = response.data.pageNum
  195. // this.table.pageSize = response.data.pageSize
  196. this.table.total = response.data.total
  197. } else {
  198. this.table.list = []
  199. }
  200. setTimeout(() => {
  201. this.table.listLoading = false
  202. }, 100)
  203. })
  204. },
  205. handleSee(row) {
  206. this.see.dialogStatus = 'see'
  207. this.see.dialogFormVisible = true
  208. this.see.temp = Object.assign({}, row)
  209. this.see.list = []
  210. this.see.getdataListParm.offset = 1
  211. this.see.getdataListParm.parammaps.feedid = row.feedid
  212. this.getSeeList()
  213. },
  214. getSeeList() {
  215. this.see.listLoading = true
  216. GetDataByName(this.see.getdataListParm).then(response => {
  217. console.log('table数据', response.data.list)
  218. if (response.data.list !== null) {
  219. this.see.list = response.data.list
  220. this.see.pageNum = response.data.pageNum
  221. this.see.pageSize = response.data.pageSize
  222. this.see.total = response.data.total
  223. } else {
  224. this.see.list = []
  225. }
  226. setTimeout(() => {
  227. this.see.listLoading = false
  228. }, 100)
  229. })
  230. },
  231. handleExport() {
  232. console.log('导出')
  233. GetDataByName(this.download.getdataListParm).then(response => {
  234. if (response.data.list !== null) {
  235. this.download.list = response.data.list
  236. } else {
  237. this.download.list = []
  238. }
  239. var excelDatas = [
  240. {
  241. tHeader: ['饲料名称', '库存量(kg)', '近七天平均计划量(kg)', '剩余使用天数', '最新预警日期'],
  242. filterVal: ['feedname', 'stockweight', 'avgweight', 'ldays', 'lastdate'],
  243. tableDatas: this.download.list,
  244. sheetName: 'Sheet1'
  245. }
  246. ]
  247. json2excel(excelDatas, '库存预警', true, 'xlsx')
  248. })
  249. }
  250. }
  251. }
  252. </script>