index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
  4. <h4 style="padding-left: 10px;line-height: 0;">导出进度:</h4>
  5. <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
  6. </div>
  7. <div class="filter-container">
  8. <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 120px;" @change="changePastureName">
  9. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  10. </el-select>
  11. <el-select v-model="getdataListParm.parammaps.departmentId" clearable placeholder="部门" class="filter-item" style="width: 120px;">
  12. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. <tree-select
  15. v-model="getdataListParm.parammaps.eqClassId"
  16. class="typeSelect"
  17. :height="150"
  18. :width="250"
  19. size="small"
  20. :data="parentClass"
  21. :default-props="defaultProps"
  22. :node-key="nodeKey"
  23. :disabled="disabled"
  24. :checked-keys="defaultCheckedKeys"
  25. :placeholder="placeholder"
  26. style="display: inline-block;top: 0;"
  27. @popoverHide="popoverHide"
  28. />
  29. <!-- <tree-select
  30. v-model="getdataListParm.parammaps.eqClassId"
  31. class="typeSelect"
  32. :height="150"
  33. :width="250"
  34. size="small"
  35. clearable
  36. :data="parentClass"
  37. :disabled="disabled"
  38. :placeholder="placeholder"
  39. style="display:inline-block;"
  40. :default-props="defaultProps"
  41. :node-key="nodeKey"
  42. :checked-keys="defaultCheckedKeys"
  43. @popoverHide="popoverHide"
  44. /> -->
  45. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  46. <el-button class="filter-item" type="success" icon="el-icon-download" @click="handleDownload">导出</el-button>
  47. <el-table
  48. :key="tableKey"
  49. v-loading="listLoading"
  50. element-loading-text="给我一点时间"
  51. :data="list"
  52. border
  53. fit
  54. highlight-current-row
  55. style="width: 100%;"
  56. :row-style="rowStyle"
  57. :cell-style="tableCellStyle"
  58. class="elTable"
  59. show-summary
  60. :max-height="myHeight"
  61. >
  62. <el-table-column label="序号" align="center" type="index" width="50px">
  63. <template slot-scope="scope">
  64. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="牧场" align="center" prop="name" />
  68. <el-table-column label="部门" align="center" prop="deapartmentName" />
  69. <el-table-column label="设备类别" min-width="70px" align="center">
  70. <template slot-scope="{row}">
  71. <a @click="clickEquipmentCategory(row)">{{ row.partClassName }}</a>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="资产标准数量" align="center" prop="equipmentNumber" />
  75. <el-table-column label="实际数量" align="center" prop="realNumber" />
  76. <el-table-column label="差异" align="center" prop="differences" />
  77. </el-table>
  78. <pagination v-show="total>=0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="get_table_data" />
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. // 引入
  84. import { GetDataByName, GetDataByNames, getRecuData, GetAccount } from '@/api/common'
  85. import waves from '@/directive/waves'
  86. import { json2excel } from '@/utils/index.js'
  87. import Pagination from '@/components/Pagination'
  88. import TreeSelect from '@/components/TreeSelect'
  89. import Cookies from 'js-cookie'
  90. export default {
  91. name: 'StandardAssetAllocation',
  92. components: { Pagination, TreeSelect },
  93. directives: { waves },
  94. data() {
  95. return {
  96. findAllPasture: [], findAllDepart: [],
  97. requestParams: [
  98. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  99. { name: 'getPastureRoleList', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid'), empId: this.$store.state.user.employeid }}
  100. ],
  101. getDepartParam: { name: 'findAllDepart1', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid'), 'eId': Cookies.get('employeid') }},
  102. disabled: false, placeholder: '请选择设备类别',
  103. nodeKey: 'id',
  104. defaultCheckedKeys: [],
  105. parentClass: [],
  106. defaultProps: { children: 'children', label: 'typeName' },
  107. getRecuListParm: { name: 'getAssetTypeList', idname: 'id', params: [-1] },
  108. tableKey: 0,
  109. list: [],
  110. total: 0,
  111. listLoading: true,
  112. getdataListParm: {
  113. name: 'getEquipmentAndEquipmentStandard', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  114. parammaps: { pastureId: Cookies.get('pastureid'), pastureName: Cookies.get('pasturename'), departmentName: '', eqClassId: '' }
  115. },
  116. requestParam: { name: 'insertAsset', offset: 0, pagecount: 0, parammaps: {}}, statueReason: false,
  117. downLoadParm: {},
  118. downLoadList: [],
  119. pageNum: 0,
  120. pageSize: 0,
  121. isPercentage: false,
  122. percentage: 1,
  123. isokDisable: false,
  124. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  125. cellStyle: { padding: 0 + 'px' },
  126. myHeight: document.documentElement.clientHeight - 85 - 150
  127. }
  128. },
  129. created() {
  130. this.get_select_list()
  131. this.get_table_data()
  132. this.getDownClassList()
  133. },
  134. methods: {
  135. get_select_list() {
  136. GetDataByNames(this.requestParams).then(response => {
  137. if (response.data.list !== null) {
  138. this.findAllPasture = response.data.getPastureRoleList.list // response.data.findAllPasture.list
  139. this.getDepartDownList()
  140. }
  141. })
  142. },
  143. getDepartDownList() {
  144. GetDataByName(this.getDepartParam).then(response => {
  145. this.findAllDepart = response.data.list
  146. })
  147. },
  148. changePastureName(item) {
  149. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  150. this.getdataListParm.parammaps.departmentId = ''
  151. this.getDepartDownList()
  152. },
  153. get_table_data() {
  154. this.listLoading = true
  155. if (this.getdataListParm.parammaps.pastureName == '现代牧业') {
  156. // this.getdataListParm.parammaps.pastureName = ''
  157. this.getdataListParm.parammaps.pastureId = ''
  158. }
  159. GetDataByName(this.getdataListParm).then(response => {
  160. console.log('table数据', response.data.list)
  161. if (response.data.list !== null) {
  162. this.list = response.data.list
  163. this.pageNum = response.data.pageNum
  164. this.pageSize = response.data.pageSize
  165. } else {
  166. this.list = []
  167. }
  168. this.total = response.data.total
  169. setTimeout(() => {
  170. this.listLoading = false
  171. }, 100)
  172. })
  173. },
  174. form_search() {
  175. this.listLoading = true
  176. this.getdataListParm.offset = 1
  177. this.getdataListParm.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == this.getdataListParm.parammaps.pastureName).id
  178. this.get_table_data()
  179. },
  180. popoverHide(checkedIds, checkedData) {
  181. console.log(checkedIds, checkedData)
  182. if (checkedData.children === undefined) {
  183. this.getdataListParm.parammaps.eqClassId = checkedData.eqClassId
  184. } else {
  185. this.defaultCheckedKeys = []
  186. this.$message({ type: 'warning', message: '请选择具体设备类型' })
  187. }
  188. },
  189. getDownClassList() {
  190. getRecuData(this.getRecuListParm).then(response => {
  191. this.parentClass = response.data
  192. })
  193. },
  194. tableCellStyle({ row, column, rowIndex, columnIndex }) {
  195. if (columnIndex === 3) {
  196. return {
  197. textDecoration: 'underline'
  198. }
  199. }
  200. return {
  201. textDecoration: 'none'
  202. }
  203. },
  204. clickEquipmentCategory(row) {
  205. console.log('跳转了')
  206. if (Cookies.get('pasturename') == '现代牧业') {
  207. this.$router.push({ path: '/asset/basics', query: { myPath: 'AssetStandardManagement', pastureName: row.name, pastureId: row.pastureId, departmentId: parseInt(row.departmentId), eqClassId: row.eqClassId }})
  208. this.getdataListParm.parammaps.pastureName = row.name
  209. this.getdataListParm.parammaps.pastureId = row.pastureId
  210. this.getdataListParm.parammaps.departmentId = row.departmentId
  211. this.getdataListParm.parammaps.eqClassId = row.eqClassId
  212. this.getdataListParm.parammaps.eqClassName = row.eqClassName
  213. } else {
  214. if (row.name == Cookies.get('pasturename')) {
  215. this.$router.push({ path: '/asset/basics', query: { myPath: 'AssetStandardManagement', pastureName: row.name, pastureId: row.pastureId, departmentId: parseInt(row.departmentId), eqClassId: row.eqClassId }})
  216. this.getdataListParm.parammaps.pastureName = row.name
  217. this.getdataListParm.parammaps.pastureId = row.pastureId
  218. this.getdataListParm.parammaps.departmentId = row.departmentId
  219. this.getdataListParm.parammaps.eqClassId = row.eqClassId
  220. this.getdataListParm.parammaps.eqClassName = row.eqClassName
  221. } else {
  222. this.$message({ type: 'error', message: '请联系管理员开通相关牧场数据权限' })
  223. }
  224. }
  225. },
  226. handleDownload() {
  227. this.$alert('设备基础信息正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  228. this.isPercentage = true
  229. this.percentage = 1
  230. var timer = setInterval(() => {
  231. this.percentage += 5
  232. if (this.percentage > 95) {
  233. this.percentage = 99
  234. clearInterval(timer)
  235. }
  236. this.percentage = this.percentage
  237. }, 1000)
  238. this.downLoadParm.name = 'getAssetList'
  239. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  240. GetAccount(this.downLoadParm).then(response => {
  241. this.downLoadList = response.data.list
  242. if (response.data.list !== '') {
  243. this.percentage = 99
  244. setTimeout(() => {
  245. this.isPercentage = false
  246. }, 2000)
  247. }
  248. console.log(this.downLoadList)
  249. const elecExcelDatas = [
  250. {
  251. tHeader: ['设备类别', '资产编号', '设备名称', '设备内部编号', '设备规格', '品牌', '供应商', '用途', '状态', '购置日期', '入场日期', '折旧年限', '财务编号', '原值', '残值', '月核减值', '保养级别', '保养费用', '维修费用', '基数(小时)', '牧场', '部门', '责任人', '录入人', '录入时间', '折旧年限', '使用时长(年)', '使用率(%)'],
  252. filterVal: ['eqClassName', 'assetCode', 'eqName', 'eqCode', 'specification', 'brandName', 'providerName', 'purpose', 'status', 'purchaseDate', 'entranceDate', 'depreciation', 'financeCode', 'yuanzhi', 'salvage', 'subtractvalue', 'upkeepgrade', 'yearUpkeepCost', 'yearMaintainCost', 'baseHours', 'pastureName', 'deptName', 'employeName', 'inputUserName', 'inputDatetime', 'depreciation', 'serviceDuration', 'utilizationRate'],
  253. tableDatas: this.downLoadList,
  254. sheetName: '设备基础信息'
  255. }
  256. ]
  257. json2excel(elecExcelDatas, '设备基础信息', true, 'xlsx')
  258. })
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. .el-autocomplete-suggestion li{
  265. padding:0 3px!important;
  266. }
  267. .el-table .warning-row {
  268. background: oldlace;
  269. }
  270. .el-table .success-row {
  271. background: #f0f9eb;
  272. }
  273. </style>
  274. <style lang="scss">
  275. .upkeepgrade .el-form-item__label{
  276. line-height: 20px;
  277. }
  278. .inputDatetime .el-range-separator{
  279. padding: 0;
  280. margin: 0 10px;
  281. }
  282. .el-radio__label{
  283. padding-left: 2px !important;
  284. }
  285. .typeSelect span .el-popover__reference .el-input--suffix {
  286. top:-3px;
  287. .el-input__inner{
  288. height:40px !important;
  289. }
  290. }
  291. </style>