index.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 120px;" @change="changePastureName">
  5. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  6. </el-select>
  7. <el-input v-model="getdataListParm.parammaps.eqName" placeholder="设备名称" style="width: 200px;" class="filter-item" />
  8. <el-input v-model="getdataListParm.parammaps.eqCode" placeholder="设备内部编号" style="width: 140px;" class="filter-item" />
  9. <tree-select
  10. class="typeSelect"
  11. :height="150"
  12. :width="250"
  13. size="small"
  14. clearable
  15. :data="parentType"
  16. :disabled="disabled"
  17. :placeholder="placeholder"
  18. style="display:inline-block;"
  19. :default-props="defaultProps"
  20. :node-key="nodeKey"
  21. :checked-keys="defaultCheckedKeys"
  22. @popoverHide="popoverHide"
  23. />
  24. <el-select v-model="getdataListParm.parammaps.departmentId" clearable placeholder="部门" class="filter-item" style="width: 120px;">
  25. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.id" />
  26. </el-select>
  27. <el-select v-model="getdataListParm.parammaps.statue" placeholder="设备状态" class="filter-item" style="width: 120px;">
  28. <el-option v-for="item in equipmentStatusList" :key="item.id" :label="item.name" :value="item.id" />
  29. </el-select>
  30. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  31. </div>
  32. <div class="month" style="height: 50px;">
  33. <el-button v-if="isMaintenancePlanCopy" type="primary" icon="el-icon-copy-document" @click="handleCopy">复制</el-button>
  34. <el-button v-if="isMaintenancePlanClear" type="danger" icon="el-icon-delete" @click="handleDelate">清空</el-button>
  35. <el-button class="filter-item" type="success" icon="el-icon-download" @click="handleDownload">导出</el-button>
  36. <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
  37. <el-button v-if="isMaintenancePlanUpload" v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
  38. </el-upload>
  39. <el-button v-waves class="filter-item" type="info" icon="el-icon-download" @click="handleDownloadTemp">模板</el-button>
  40. <el-date-picker v-model="getdataListParm.month" type="month" placeholder="选择日期" format="yyyy-MM" value-format="yyyy-MM" :clearable="false" style="float: right" @blur="blurMonth" />
  41. </div>
  42. <el-table
  43. slot="reference"
  44. border
  45. :data="list"
  46. header-align="center"
  47. :row-style="rowStyle"
  48. :cell-style="tableCellClassName"
  49. @cell-click="handleCellClick"
  50. >
  51. <template v-for="(item,index) in tablelist">
  52. <el-table-column :key="index" show-overflow-tooltip :prop="item.column_name" :label="item.label" :width="item.width" />
  53. </template>
  54. </el-table>
  55. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  56. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="50%">
  57. <div class="content-add">
  58. <el-form
  59. ref="createTemp"
  60. :rules="rules"
  61. :model="createTemp"
  62. label-position="right"
  63. label-width="95px"
  64. style="width:90%;margin:0 auto"
  65. >
  66. <el-row>
  67. <el-col :span="20">
  68. <el-form-item label="保养名称:" prop="upkeepTemplateId">
  69. <el-select v-model="createTemp.upkeepTemplateId" filterable placeholder="请选择" @change="changeUpkeep">
  70. <el-option
  71. v-for="item in upkeepTemps"
  72. :key="item.id"
  73. :label="item.name"
  74. :value="item.id"
  75. />
  76. </el-select>
  77. </el-form-item>
  78. </el-col>
  79. </el-row>
  80. <el-row>
  81. <el-col :span="20">
  82. <el-form-item label="保养人:" prop="upkeepEmpId">
  83. <el-select v-model="createTemp.upkeepEmpId" filterable placeholder="请选择">
  84. <el-option
  85. v-for="item in findAllEmploye"
  86. :key="item.id"
  87. :label="item.name"
  88. :value="item.id"
  89. />
  90. </el-select>
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. </el-form>
  95. <div slot="footer" class="dialog-footer" style="bottom:10px">
  96. <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  97. <el-button @click="dialogFormVisible = false;">关闭</el-button>
  98. </div>
  99. </div>
  100. </el-dialog>
  101. <!-- 修改计划/删除计划/提前保养 -->
  102. <el-dialog :title="textMap[dialogStatusBtn]" :visible.sync="dialogFormVisibleBtn" :close-on-click-modal="false" width="450px;" style="width:45%;margin:0 auto">
  103. <div class="content-btn">
  104. <el-button class="filter-item" type="primary" @click="handleRevisionPlan">修改计划</el-button>
  105. <el-button class="filter-item" type="danger" @click="handleDeletionPlan">删除计划</el-button>
  106. <el-button class="filter-item" type="warning" @click="handleAdvanceMaintenance">提前保养</el-button>
  107. </div>
  108. </el-dialog>
  109. <!-- 复制 -->
  110. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisibleCopy" :close-on-click-modal="false" width="50%" style="width:90%;margin:0 auto">
  111. <div class="app-copy">
  112. <el-form ref="copyTemp" :rules="rules" :model="copyTemp" label-position="right" label-width="110px" style="width: 90%; margin: 0 auto;">
  113. <el-row>
  114. <el-col :span="12" label="月份:">
  115. <el-form-item>
  116. <el-select v-model="month" placeholder="月份" multiple style="width:100%">
  117. <el-option v-for="item in months" :key="item.id" :label="item.name" :value="item.name" />
  118. </el-select>
  119. </el-form-item>
  120. </el-col>
  121. </el-row>
  122. </el-form>
  123. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
  124. <el-button type="primary" @click="dialogStatus==='copy'?createCopyData():createCopyData()">确认</el-button>
  125. <el-button @click="dialogFormVisibleCopy = false">关闭</el-button>
  126. </div>
  127. </div>
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. // 引入
  133. import { GetDataByName, GetDataByNames, transData, GetUpkeepPlan, PostDataByName, failproccess, ExecDataByConfig, checkButtons,GetAccount } from '@/api/common'
  134. import waves from '@/directive/waves' // waves directive
  135. import Pagination from '@/components/Pagination'
  136. import { parseTime, json2excel } from '@/utils/index.js'
  137. import { MessageBox } from 'element-ui'
  138. import TreeSelect from '@/components/TreeSelect'
  139. import Cookies from 'js-cookie'
  140. import { getToken } from '@/utils/auth'
  141. export default {
  142. name: 'MaintenancePlan',
  143. components: { Pagination, TreeSelect },
  144. directives: { waves },
  145. data() {
  146. return {
  147. // ----------------------------------------------------
  148. equipmentStatusList: [{ id: 1, name: '正常设备' }, { id: 2, name: '非正常设备' }, { id: '', name: '全部' }],
  149. visible: false,
  150. findAllPasture: [],
  151. findAllDepart: [],
  152. requestParams: [
  153. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  154. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
  155. ],
  156. getDepartParam: {
  157. name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }
  158. },
  159. disabled: false,
  160. parentType: [],
  161. placeholder: '设备类别',
  162. getParmType: {
  163. name: 'geteqclasslist'
  164. },
  165. defaultProps: {
  166. children: 'children',
  167. label: 'typeName'
  168. },
  169. nodeKey: 'id',
  170. defaultCheckedKeys: [],
  171. dataform: {
  172. id: '',
  173. name: '',
  174. selectType: [],
  175. sort: '',
  176. enable: '',
  177. typeCode: ''
  178. },
  179. UpdateDataRelationParam: {
  180. name: '',
  181. dataname: '',
  182. datavalue: '',
  183. valuename: '',
  184. values: ''
  185. },
  186. rowStyle: { maxHeight: 30 + 'px', height: 25 + 'px' },
  187. total: 0,
  188. tableKey: 0,
  189. listLoading: true,
  190. list: [],
  191. listTest: {},
  192. updateValue: {},
  193. tablelist: [],
  194. getdataListParm: {
  195. name: 'geteqList',
  196. page: 1,
  197. offset: 1,
  198. pagecount: 10,
  199. returntype: 'Map',
  200. parammaps: {
  201. pastureName: Cookies.get('pasturename'),
  202. eqCode: '',
  203. eqName: '',
  204. typeCode: '',
  205. partName: '',
  206. statue: 1
  207. },
  208. month: parseTime(new Date(), '{y}-{m}')
  209. },
  210. getdataListParmSH: {
  211. name: 'geteqList',
  212. page: 0,
  213. offset: 0,
  214. pagecount: 0,
  215. returntype: 'Map',
  216. parammaps: {
  217. pastureName: Cookies.get('pasturename'),
  218. eqCode: '',
  219. eqName: '',
  220. typeCode: '',
  221. partName: '',
  222. statue: 1
  223. },
  224. month: parseTime(new Date(), '{y}-{m}')
  225. },
  226. dialogStatus: '',
  227. dialogFormVisible: false,
  228. dialogStatusBtn: '',
  229. dialogFormVisibleBtn: false,
  230. isokDisable: false,
  231. rules: {
  232. upkeepTemplateId: [{ required: true, message: '必填', trigger: 'blur' }],
  233. upkeepEmpId: [{ required: true, message: '必填', trigger: 'blur' }]
  234. },
  235. textMap: {
  236. create: '添加保养计划',
  237. update: '修改保养计划',
  238. copy: '复制'
  239. },
  240. listAdd: [],
  241. createTemp: {
  242. upkeepTemplateId: '',
  243. upkeepEmpId: ''
  244. },
  245. postDataPramas: {},
  246. requestParam: {},
  247. getParmUpemplateByeq: {
  248. name: 'getUpemplateByeq',
  249. parammaps: {}
  250. },
  251. getParmUpdatePlan: {
  252. name: 'getseviceplanbyid',
  253. parammaps: {}
  254. },
  255. upkeepTemps: [],
  256. findAllEmploye: [],
  257. dialogFormVisibleCopy: false,
  258. months: [],
  259. copyTemp: {},
  260. month: [],
  261. downLoadParm: {},
  262. downLoadList: [],
  263. buttons: [],
  264. isMaintenancePlanCopy: [], isMaintenancePlanUpload: [], isMaintenancePlanClear: [], isMaintenancePlanAdd: [], isMaintenancePlanUpdate: []
  265. }
  266. },
  267. computed: {
  268. // 设置请求头
  269. headers() {
  270. return {
  271. // 设置token
  272. // eslint-disable-next-line no-undef
  273. token: getToken()
  274. }
  275. },
  276. uploadData() {
  277. return {
  278. name: 'uploadSevicplan',
  279. importParams: '月份,部门名称,编码,资产名称,牧场,保养人,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
  280. sheetname: 'SheetJS'
  281. }
  282. },
  283. // 设置上传地址
  284. uploadExcelUrl() {
  285. // process.env.VUE_APP_BASE_API是服务器的路径,也是axios的基本路径
  286. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  287. }
  288. },
  289. created() {
  290. if (this.$route.query.myPath !== undefined && this.$route.query.myPath == 'CompletionRateMaintenance') {
  291. if (this.$route.query.pastureName !== undefined && this.$route.query.eqCode !== undefined) {
  292. this.getdataListParm.parammaps.pastureName = this.$route.query.pastureName
  293. this.getdataListParm.parammaps.eqCode = this.$route.query.eqCode
  294. this.$forceUpdate()
  295. } else {
  296. this.getdataListParm.parammaps.pastureName = Cookies.get('pasturename')
  297. this.getdataListParm.parammaps.eqCode = ''
  298. }
  299. this.getList()
  300. } else {
  301. if (this.$route.query.pastureName !== undefined && this.$route.query.eqCode !== undefined) {
  302. this.getdataListParm.parammaps.pastureName = this.$route.query.pastureName
  303. this.getdataListParm.parammaps.eqCode = this.$route.query.eqCode
  304. } else {
  305. this.getdataListParm.parammaps.pastureName = Cookies.get('pasturename')
  306. this.getdataListParm.parammaps.eqCode = ''
  307. }
  308. this.getList()
  309. }
  310. this.getTypeList()
  311. this.get_select_list()
  312. this.getMonths()
  313. const that = this
  314. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  315. that.buttons = response.data.list
  316. that.get_auto_buttons()
  317. })
  318. // 新增
  319. },
  320. methods: {
  321. get_auto_buttons() {
  322. // 复制
  323. const MaintenancePlanCopy = 'maintenance:maintenancePlan:copy'
  324. const isMaintenancePlanCopy = checkButtons(this.$store.state.user.buttons, MaintenancePlanCopy)
  325. this.isMaintenancePlanCopy = isMaintenancePlanCopy
  326. // 导入
  327. const MaintenancePlanUpload = 'maintenance:maintenancePlan:upload'
  328. const isMaintenancePlanUpload = checkButtons(this.$store.state.user.buttons, MaintenancePlanUpload)
  329. this.isMaintenancePlanUpload = isMaintenancePlanUpload
  330. // 清空
  331. const MaintenancePlanClear = 'maintenance:maintenancePlan:clear'
  332. const isMaintenancePlanClear = checkButtons(this.$store.state.user.buttons, MaintenancePlanClear)
  333. this.isMaintenancePlanClear = isMaintenancePlanClear
  334. // 新增
  335. const MaintenancePlanAdd = 'maintenance:maintenancePlan:add'
  336. const isMaintenancePlanAdd = checkButtons(this.$store.state.user.buttons, MaintenancePlanAdd)
  337. this.isMaintenancePlanAdd = isMaintenancePlanAdd
  338. // 编辑
  339. const MaintenancePlanUpdate = 'maintenance:maintenancePlan:update'
  340. const isMaintenancePlanUpdate = checkButtons(this.$store.state.user.buttons, MaintenancePlanUpdate)
  341. this.isMaintenancePlanUpdate = isMaintenancePlanUpdate
  342. },
  343. popoverHide(checkedIds, checkedData) {
  344. console.log('选中值', checkedIds, checkedData)
  345. if (checkedData == null) {
  346. this.dataform.eqClassId = checkedIds
  347. this.dataform.typeCode = ''
  348. } else {
  349. this.dataform.eqClassId = checkedIds
  350. this.dataform.typeCode = checkedData.typeCode
  351. }
  352. },
  353. getTypeList() {
  354. GetDataByName(this.getParmType).then(response => {
  355. if (response.data.list !== null) {
  356. this.parentType = transData(response.data.list, 'id', 'pid', 'children')
  357. }
  358. })
  359. },
  360. get_select_list() {
  361. GetDataByNames(this.requestParams).then(response => {
  362. this.findAllPasture = response.data.findAllPasture.list
  363. this.findAllEmploye = response.data.findAllEmploye.list
  364. this.getDepartDownList()
  365. })
  366. },
  367. getDepartDownList() {
  368. GetDataByName(this.getDepartParam).then(response => {
  369. this.findAllDepart = response.data.list
  370. })
  371. },
  372. changePastureName(item) {
  373. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  374. this.getdataListParm.parammaps.departmentId = ''
  375. this.getDepartDownList()
  376. },
  377. getList() {
  378. this.listLoading = true
  379. // this.getdataListParm.month = parseTime(new Date(), '{y}-{m}') // 更改为请求的月份
  380. // this.getdataListParm.month = '2020-03' // 更改为请求的月份
  381. GetUpkeepPlan(this.getdataListParm).then(response => {
  382. console.log('table数据', response.data.list)
  383. this.list = response.data.list
  384. this.pageNum = response.data.pageNum
  385. this.pageSize = response.data.pageSize
  386. if (response.data.total) {
  387. this.total = response.data.total
  388. }
  389. var temp = this.getdataListParm.month.split('-')
  390. var year = temp[0]
  391. var month = temp[1]
  392. var d = new Date(year, month, 0)
  393. var table = [{ 'label': '序号', 'column_name': 'i' }, { 'label': '牧场', 'column_name': 'pastureName' }, { 'label': '部门', 'column_name': 'deptName' }, { 'label': '设备名称', 'column_name': 'eqName' }, { 'label': '设备内部编号', 'column_name': 'eqCode' }, { 'label': '品牌', 'column_name': 'brand' }]
  394. for (let index = 1; index <= d.getDate(); index++) {
  395. // eslint-disable-next-line no-undef
  396. index = JSON.stringify(index)
  397. var m = { 'label': index, 'column_name': 'm' + index, 'width': '40' }
  398. table.push(m)
  399. }
  400. var operation = { 'label': '操作', 'column_name': 'operation', 'width': '100' }
  401. table.push(operation)
  402. this.tablelist = table
  403. for (var i = 0; i < this.list.length; i++) {
  404. this.list[i].i = i + 1
  405. if (this.isMaintenancePlanClear !== false) {
  406. this.list[i].operation = <el-button type='danger' size='mini' style='width:60px;' ref='clear' id='clear' class-name='small-padding fixed-width' fixed='right'>清空</el-button>
  407. }
  408. // this.list[i].operation = '操作'
  409. for (const key in this.list[i]) {
  410. // console.log(key + '---' + this.list[i][key])
  411. // this.list[i][key] = (this.list[i][key]).split('#')[0]
  412. var reg = /^(?![^a-zA-Z]+$)(?!\D+$)/
  413. // console.log(reg.test(key))
  414. // console.log((this.list[i][key]))
  415. if (reg.test(key)) {
  416. // console.log(reg.test(key))
  417. var a = JSON.stringify(i)
  418. if (this.list[i][key] !== undefined) {
  419. if ((this.list[i][key]).split('#')[0] == undefined) {
  420. this.listTest[key + a] = this.list[i][key]
  421. this.list[i][key] = ''
  422. } else {
  423. this.listTest[key + a] = this.list[i][key]
  424. this.list[i][key] = (this.list[i][key]).split('#')[0]
  425. }
  426. }
  427. }
  428. }
  429. }
  430. console.log('table数据', this.list)
  431. console.log('表头数据', this.tablelist)
  432. this.$forceUpdate()
  433. setTimeout(() => {
  434. this.listLoading = false
  435. }, 100)
  436. })
  437. },
  438. blurMonth() {
  439. this.listLoading = true
  440. if (this.dataform.eqClassId == null) {
  441. this.getdataListParm.parammaps.typeCode = ''
  442. } else {
  443. this.getdataListParm.parammaps.typeCode = this.dataform.typeCode
  444. }
  445. this.getList()
  446. },
  447. form_search() {
  448. this.listLoading = true
  449. if (this.dataform.eqClassId == null) {
  450. this.getdataListParm.parammaps.typeCode = ''
  451. } else {
  452. this.getdataListParm.parammaps.typeCode = this.dataform.typeCode
  453. }
  454. this.getdataListParm.offset = 1
  455. this.getList()
  456. },
  457. tableCellClassName({ row, column, rowIndex, columnIndex }) {
  458. row.index = rowIndex
  459. column.index = columnIndex
  460. var rowStr = JSON.stringify(rowIndex)
  461. var test = this.listTest[this.tablelist[column.index].column_name + rowStr]
  462. if (test !== undefined) {
  463. if (test.split('#')[2] !== undefined) {
  464. var colorTest = test.split('#')[2] // 0,1,2
  465. var colorTest2 = test.split('#')[4] // 0,1,2
  466. console.log(colorTest2,'colorTest2')
  467. let cellStyle
  468. if (parseFloat(colorTest2) !== 0) {
  469. cellStyle = 'background: #E6A23C;color:#fff;width:48px'
  470. } else {
  471. switch (colorTest) {
  472. case '0':
  473. cellStyle = 'background: #4169E1;color:#fff;width:48px'
  474. break
  475. case '1':
  476. cellStyle = 'background: #00FF00;color:#fff'
  477. break
  478. case '2':
  479. cellStyle = 'background: red;color:#fff'
  480. break
  481. default:
  482. cellStyle = 'background: #4169E1;color:#fff'
  483. }
  484. }
  485. if (columnIndex >= 6 && row[this.tablelist[column.index].column_name] == test.split('#')[0]) {
  486. return cellStyle
  487. }
  488. } else {
  489. const cellStyle = 'background: #4169E1;color:#fff'
  490. if (columnIndex >= 6 && row[this.tablelist[column.index].column_name] == test.split('#')[0]) {
  491. return cellStyle
  492. }
  493. }
  494. }
  495. },
  496. resetCreateTemp() {
  497. this.createTemp.upkeepTemplateId = ''
  498. this.listAdd = []
  499. },
  500. handleCellClick(row, column, rowIndex, columnIndex) {
  501. // console.log(this.getdataListParm.month)
  502. // console.log(parseTime(new Date(), '{y}-{m}-{d}'))
  503. var day
  504. if (this.tablelist[column.index].label < 10) {
  505. day = '0' + this.tablelist[column.index].label
  506. } else {
  507. day = this.tablelist[column.index].label
  508. }
  509. if (this.getdataListParm.month + '-' + day > parseTime(new Date(), '{y}-{m}-{d}')) {
  510. this.getParmUpemplateByeq.parammaps.assetCode = row.assetCode
  511. this.getUpemplateByeq()
  512. // console.log('row', row)
  513. // console.log('table数据', this.list)
  514. // console.log('行索引', rowIndex)
  515. // console.log('lie索引', columnIndex)
  516. // console.log('引', column.index)
  517. if (column.index > 5) {
  518. // console.log('row--行', row)
  519. // console.log('--列索引', column.index)
  520. // console.log('--行索引', row.index)
  521. console.log('--表头', this.tablelist[column.index])
  522. console.log('row[this.tablelist[column.index].column_name]', row[this.tablelist[column.index].column_name])
  523. // console.log('row[this.tablelist[column.index].column_name].elm', row[this.tablelist[column.index].column_name].elm)
  524. if (column.index >= 6 && row[this.tablelist[column.index].column_name] !== undefined) {
  525. console.log(row[this.tablelist[column.index].column_name].elm)
  526. if (row[this.tablelist[column.index].column_name].elm == undefined) {
  527. // console.log(row[this.tablelist[column.index].column_name])
  528. // console.log(row[this.tablelist[column.index].column_name])
  529. var rowStr = JSON.stringify(row.index)
  530. // console.log(this.tablelist[column.index].column_name + rowStr)
  531. // 要分割值
  532. this.updateValue = this.listTest[this.tablelist[column.index].column_name + rowStr]
  533. console.log('要分割值', this.updateValue)
  534. console.log('--年月', this.getdataListParm.month)
  535. console.log(this.updateValue.split('#')[4])
  536. if (this.updateValue.split('#')[4] == 0) {
  537. console.log(this.isMaintenancePlanAdd, this.isMaintenancePlanUpdate)
  538. if (this.isMaintenancePlanUpdate == true) {
  539. this.dialogFormVisibleBtn = true
  540. }
  541. }
  542. this.createTemp.pastureId = row.pastureId
  543. this.createTemp.deptId = row.deptId
  544. this.createTemp.eqName = row.eqName
  545. this.createTemp.eqCode = row.eqCode
  546. this.createTemp.eqId = row.id
  547. this.createTemp.eqClassId = row.eqClassId
  548. this.createTemp.bigupkeeptemplateId = row.upkeepTemplateId
  549. this.createTemp.month = this.getdataListParm.month
  550. this.createTemp.upkeepType = row.upkeepType
  551. this.createTemp.upkeepCycel = row.upkeepCycel
  552. this.createTemp.upkeepName = row.upkeepName
  553. this.createTemp.id = this.updateValue.split('#')[1]
  554. this.createTemp.upkeepEmpId = row.upkeepEmpId
  555. this.createTemp.day = this.tablelist[column.index].label
  556. console.log('---------------------', row)
  557. } else {
  558. MessageBox.confirm('是否清空本设备本月保养计划?', {
  559. confirmButtonText: '确认',
  560. cancelButtonText: '取消',
  561. type: 'warning'
  562. }).then(() => {
  563. this.requestParam.name = 'ClearoneSevicplan'
  564. this.requestParam.parammaps = {}
  565. this.requestParam.parammaps.id = row.id
  566. this.requestParam.parammaps.monthIN = this.getdataListParm.month
  567. PostDataByName(this.requestParam).then(() => {
  568. this.getList()
  569. this.dialogFormVisible = false
  570. this.$notify({ title: '成功', message: '清空成功', type: 'success', duration: 2000 })
  571. })
  572. }).catch(() => {
  573. this.$message({ type: 'info', message: '已取消清空' })
  574. })
  575. }
  576. } else {
  577. console.log('--年月', this.getdataListParm.month)
  578. console.log('--日', this.tablelist[column.index].label)
  579. this.resetCreateTemp()
  580. this.createTemp.pastureId = row.pastureId
  581. this.createTemp.deptId = row.deptId
  582. this.createTemp.eqName = row.eqName
  583. this.createTemp.eqCode = row.eqCode
  584. this.createTemp.eqId = row.id
  585. this.createTemp.eqClassId = row.eqClassId
  586. this.createTemp.month = this.getdataListParm.month
  587. this.createTemp.day = this.tablelist[column.index].label
  588. this.dialogStatus = 'create'
  589. console.log(this.isMaintenancePlanAdd, this.isMaintenancePlanUpdate)
  590. if (this.isMaintenancePlanAdd == true) {
  591. this.dialogFormVisible = true
  592. }
  593. }
  594. }
  595. } else {
  596. console.log('点击后期跳转', row, column, rowIndex, columnIndex)
  597. var str = 'm' + column.label
  598. console.log(str, 'str')
  599. console.log(row.str, 'row.str')
  600. console.log(row['m' + column.label], '====')
  601. if (row['m' + column.label] !== undefined && row['m' + column.label] !== '') {
  602. var time = this.getdataListParm.month + '-' + day
  603. if (Cookies.get('pasturename') == '现代牧业') {
  604. this.$router.push({ path: '/maintenance/maintain', query: { myPath: 'MaintenancePlan', eqCode: row.eqCode, time: time }})
  605. } else {
  606. if (row.pastureName == Cookies.get('pasturename')) {
  607. this.$router.push({ path: '/maintenance/maintain', query: { myPath: 'MaintenancePlan', eqCode: row.eqCode, time: time }})
  608. } else {
  609. this.$message({ type: 'error', message: '请联系管理员开通相关牧场数据权限' })
  610. }
  611. }
  612. }
  613. }
  614. },
  615. getUpemplateByeq() {
  616. GetDataByName(this.getParmUpemplateByeq).then(response => {
  617. if (response.data.list !== null) {
  618. this.upkeepTemps = response.data.list
  619. for (var i = 0; i < this.upkeepTemps.length; i++) {
  620. this.upkeepTemps[i].name = this.upkeepTemps[i].upkeepName + '|' + this.upkeepTemps[i].upkeepType + '|' + this.upkeepTemps[i].upkeepLevel
  621. }
  622. }
  623. })
  624. },
  625. changeUpkeep(item) {
  626. console.log('保养名称', item)
  627. console.log(this.upkeepTemps.find(obj => obj.id === item))
  628. this.createTemp.upkeepTemplateId = item
  629. this.createTemp.upkeepType = this.upkeepTemps.find(obj => obj.id === item).upkeepType
  630. this.createTemp.upkeepCycel = this.upkeepTemps.find(obj => obj.id === item).upkeepCycel
  631. this.createTemp.upkeepName = this.upkeepTemps.find(obj => obj.id === item).upkeepName
  632. },
  633. add_dialog_save() {
  634. this.isokDisable = true
  635. setTimeout(() => {
  636. this.isokDisable = false
  637. }, 1000)
  638. for (var i = parseInt(this.createTemp.day); i < this.tablelist.length - 5; i += this.createTemp.upkeepCycel) {
  639. // this.listAdd.push()
  640. var listObj = {}
  641. listObj.pastureId = this.createTemp.pastureId
  642. listObj.deptId = this.createTemp.deptId
  643. listObj.eqName = this.createTemp.eqName
  644. listObj.eqCode = this.createTemp.eqCode
  645. listObj.eqId = this.createTemp.eqId
  646. listObj.eqClassId = this.createTemp.eqClassId
  647. listObj.upkeepPerson = this.createTemp.upkeepEmpId
  648. listObj.bigupkeeptemplateId = this.createTemp.upkeepTemplateId
  649. var b = i
  650. if (b < 10) {
  651. listObj.plantime = this.createTemp.month + '-' + '0' + b
  652. } else {
  653. listObj.plantime = this.createTemp.month + '-' + b
  654. }
  655. this.listAdd.push(listObj)
  656. }
  657. console.log('this.listAdd', this.listAdd)
  658. this.$refs['createTemp'].validate(valid => {
  659. this.postDataPramas.common = { 'returnmap': '0' }
  660. this.postDataPramas.data = []
  661. this.postDataPramas.data[0] = { 'name': 'insertseviceplan', 'type': 'e', 'parammaps': {
  662. pastureId: this.createTemp.pastureId,
  663. deptId: this.createTemp.deptId,
  664. eqName: this.createTemp.eqName,
  665. eqCode: this.createTemp.eqCode,
  666. eqId: this.createTemp.eqId,
  667. eqClassId: this.createTemp.eqClassId,
  668. upkeepTemplateId: this.createTemp.upkeepTemplateId,
  669. upkeepType: this.createTemp.upkeepType,
  670. upkeepCycel: this.createTemp.upkeepCycel,
  671. upkeepName: this.createTemp.upkeepName,
  672. month: this.createTemp.month,
  673. day: this.createTemp.day,
  674. upkeepEmpId: this.createTemp.upkeepEmpId
  675. }}
  676. // eslint-disable-next-line no-irregular-whitespace
  677. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
  678. this.postDataPramas.data[1].children = []
  679. this.postDataPramas.data[1].children[0] = { 'name': 'insertBigupKeep', 'type': 'e', 'parammaps': {
  680. seviceplanId: '@insertseviceplan.LastInsertId',
  681. pastureId: '@insertSpotList.pastureId',
  682. deptId: '@insertSpotList.deptId',
  683. eqName: '@insertSpotList.eqName',
  684. eqCode: '@insertSpotList.eqCode',
  685. eqId: '@insertSpotList.eqId',
  686. eqClassId: '@insertSpotList.eqClassId',
  687. bigupkeeptemplateId: '@insertSpotList.bigupkeeptemplateId',
  688. plantime: '@insertSpotList.plantime',
  689. upkeepPerson: '@insertSpotList.upkeepPerson'
  690. }}
  691. ExecDataByConfig(this.postDataPramas).then(response => {
  692. console.log('新增保存发送参数', this.postDataPramas)
  693. if (response.msg === 'fail') {
  694. this.$notify({
  695. title: '保存失败',
  696. message: response.data,
  697. type: 'warning',
  698. duration: 2000
  699. })
  700. } else {
  701. this.dialogFormVisible = false
  702. this.getdataListParm.parammaps.inputDatetime = ''
  703. this.getList()
  704. this.$notify({
  705. title: '',
  706. message: '保存成功',
  707. type: 'success',
  708. duration: 2000
  709. })
  710. }
  711. })
  712. })
  713. },
  714. handleRevisionPlan() {
  715. console.log('点击了修改计划', this.updateValue)
  716. console.log('年月', this.getdataListParm.month)
  717. this.dialogFormVisibleBtn = false
  718. this.dialogStatus = 'update'
  719. this.dialogFormVisible = true
  720. this.getUpdatePlan()
  721. },
  722. getUpdatePlan() {
  723. this.getParmUpdatePlan.parammaps.id = (this.updateValue).split('#')[1]
  724. GetDataByName(this.getParmUpdatePlan).then(response => {
  725. if (response.data.list !== null) {
  726. console.log(response.data.list[0])
  727. this.createTemp.id = response.data.list[0].id
  728. this.createTemp.upkeepCycel = response.data.list[0].upkeepCycel
  729. this.createTemp.upkeepEmpId = response.data.list[0].upkeepEmpId
  730. this.createTemp.upkeepName = response.data.list[0].upkeepName
  731. this.createTemp.upkeepTemplateId = response.data.list[0].upkeepTemplateId
  732. this.createTemp.upkeepType = response.data.list[0].upkeepType
  733. }
  734. })
  735. },
  736. edit_dialog_save() {
  737. this.isokDisable = true
  738. setTimeout(() => {
  739. this.isokDisable = false
  740. }, 1000)
  741. // for (var i = parseInt(this.createTemp.upkeepCycel); i < this.tablelist.length - 5; i += this.createTemp.upkeepCycel) {
  742. // // this.listAdd.push()
  743. // var listObj = {}
  744. // listObj.pastureId = this.createTemp.pastureId
  745. // listObj.deptId = this.createTemp.deptId
  746. // listObj.eqName = this.createTemp.eqName
  747. // listObj.eqCode = this.createTemp.eqCode
  748. // listObj.eqId = this.createTemp.eqId
  749. // listObj.eqClassId = this.createTemp.eqClassId
  750. // listObj.upkeepPerson = this.createTemp.upkeepEmpId
  751. // listObj.bigupkeeptemplateId = this.createTemp.upkeepTemplateId
  752. // var b = i
  753. // if (b < 10) {
  754. // listObj.plantime = this.createTemp.month + '-' + '0' + b
  755. // } else {
  756. // listObj.plantime = this.createTemp.month + '-' + b
  757. // }
  758. // this.listAdd.push(listObj)
  759. // }
  760. console.log('this.listAdd', this.listAdd)
  761. this.$refs['createTemp'].validate(valid => {
  762. this.postDataPramas.common = { 'returnmap': '0' }
  763. this.postDataPramas.data = []
  764. this.postDataPramas.data[0] = { 'name': 'updateseviceplanId', 'type': 'e', 'parammaps': {
  765. id: (this.updateValue).split('#')[3]
  766. }}
  767. this.postDataPramas.data[1] = { 'name': 'insertseviceplan', 'type': 'e', 'parammaps': {
  768. pastureId: this.createTemp.pastureId,
  769. deptId: this.createTemp.deptId,
  770. eqName: this.createTemp.eqName,
  771. eqCode: this.createTemp.eqCode,
  772. eqId: this.createTemp.eqId,
  773. eqClassId: this.createTemp.eqClassId,
  774. upkeepTemplateId: this.createTemp.upkeepTemplateId,
  775. upkeepType: this.createTemp.upkeepType,
  776. upkeepCycel: this.createTemp.upkeepCycel,
  777. upkeepName: this.createTemp.upkeepName,
  778. month: this.createTemp.month,
  779. day: this.createTemp.day,
  780. upkeepEmpId: this.createTemp.upkeepEmpId
  781. }}
  782. this.postDataPramas.data[2] = { 'name': 'updateBigUpkeep', 'type': 'e', 'parammaps': {
  783. id: (this.updateValue).split('#')[3],
  784. bigupkeeptemplateId: this.createTemp.upkeepTemplateId,
  785. seviceplanId: '@insertseviceplan.LastInsertId',
  786. upkeepPerson: this.createTemp.upkeepEmpId
  787. }}
  788. ExecDataByConfig(this.postDataPramas).then(response => {
  789. console.log('新增保存发送参数', this.postDataPramas)
  790. if (response.msg === 'fail') {
  791. this.$notify({
  792. title: '保存失败',
  793. message: response.data,
  794. type: 'warning',
  795. duration: 2000
  796. })
  797. } else {
  798. this.dialogFormVisible = false
  799. this.getdataListParm.parammaps.inputDatetime = ''
  800. this.getList()
  801. this.$notify({
  802. title: '',
  803. message: '保存成功',
  804. type: 'success',
  805. duration: 2000
  806. })
  807. }
  808. })
  809. })
  810. },
  811. handleDeletionPlan() {
  812. console.log('点击了删除计划')
  813. this.dialogFormVisibleBtn = false
  814. MessageBox.confirm('是否删除本天保养计划?', {
  815. confirmButtonText: '确认',
  816. cancelButtonText: '取消',
  817. type: 'warning'
  818. }).then(() => {
  819. this.requestParam.name = 'deleteBigUpkeep'
  820. this.requestParam.parammaps = {}
  821. console.log('要分割值', this.updateValue)
  822. this.requestParam.parammaps.id = (this.updateValue).split('#')[3]
  823. PostDataByName(this.requestParam).then(() => {
  824. this.getList()
  825. this.dialogFormVisible = false
  826. this.$notify({
  827. title: '成功',
  828. message: '删除成功',
  829. type: 'success',
  830. duration: 2000
  831. })
  832. })
  833. }).catch(() => {
  834. this.$message({
  835. type: 'info',
  836. message: '已取消删除'
  837. })
  838. })
  839. },
  840. // 提前保养
  841. handleAdvanceMaintenance() {
  842. console.log('点击了提前保养', this.updateValue)
  843. MessageBox.confirm('是否确认提前一天保养本设备?', {
  844. confirmButtonText: '确认',
  845. cancelButtonText: '取消',
  846. type: 'warning'
  847. }).then(() => {
  848. this.isokDisable = true
  849. setTimeout(() => {
  850. this.isokDisable = false
  851. }, 1000)
  852. this.postDataPramas.common = { 'returnmap': '0' }
  853. this.postDataPramas.data = []
  854. this.postDataPramas.data[0] = { 'name': 'advanceBigupkeep', 'type': 'e', 'parammaps': {
  855. id: this.updateValue.split('#')[3]
  856. }}
  857. this.postDataPramas.data[1] = { 'name': 'updateadvanceupkeep', 'type': 'e', 'parammaps': {
  858. id: this.updateValue.split('#')[3],
  859. advanceId: '@advanceBigupkeep.LastInsertId'
  860. }}
  861. this.postDataPramas.data[2] = { 'name': 'advanceBupUt', 'type': 'e', 'parammaps': {
  862. bigupkeeptemplateId: this.updateValue.split('#')[1],
  863. id: '@advanceBigupkeep.LastInsertId'
  864. }}
  865. ExecDataByConfig(this.postDataPramas).then(response => {
  866. console.log('提前保养发送参数', this.postDataPramas)
  867. if (response.msg === 'fail') {
  868. // key 'pastureId'
  869. var pmonth = new RegExp("key 'pastureId'")
  870. if (pmonth.test(response.data)) {
  871. this.$notify({
  872. title: '',
  873. message: '前一天已有保养计划,不可重复添加',
  874. type: 'warning',
  875. duration: 2000
  876. })
  877. } else {
  878. this.$notify({
  879. title: '保存失败',
  880. message: '参数错误',
  881. type: 'warning',
  882. duration: 2000
  883. })
  884. }
  885. } else {
  886. this.dialogFormVisibleBtn = false
  887. this.getdataListParm.parammaps.inputDatetime = ''
  888. this.getList()
  889. this.$notify({
  890. title: '',
  891. message: '保存成功',
  892. type: 'success',
  893. duration: 2000
  894. })
  895. }
  896. })
  897. })
  898. },
  899. getMonths() {
  900. var data = new Date()
  901. data.setMonth(data.getMonth(), 1) // 获取到当前月份,设置月份
  902. for (var i = 0; i < 12; i++) {
  903. data.setMonth(data.getMonth() + 1) // 每次循环一次 月份值减1
  904. var m = data.getMonth() + 1
  905. m = m < 10 ? '0' + m : m
  906. var monthObj = {}
  907. monthObj.id = i
  908. monthObj.name = data.getFullYear() + '-' + m
  909. this.months.push(monthObj)
  910. }
  911. console.log(this.months, '---------------')
  912. },
  913. handleCopy() {
  914. this.dialogStatus = 'copy'
  915. this.dialogFormVisibleCopy = true
  916. },
  917. createCopyData() {
  918. console.log(this.month)
  919. if (this.month.length === 0) {
  920. this.$message({
  921. message: '请选择设备',
  922. type: 'warning',
  923. duration: 2000
  924. })
  925. } else {
  926. var selectMonth = []
  927. for (var i = 0; i < this.month.length; i++) {
  928. var checkedIdsObj = {}
  929. checkedIdsObj['NewmonthIN'] = this.month[i]
  930. selectMonth.push(checkedIdsObj)
  931. }
  932. console.log('处理选中值', selectMonth)
  933. this.dialogStatusCopy = 'copy'
  934. this.dialogFormVisibleCopy = true
  935. this.postDataPramas.common = { 'returnmap': '0' }
  936. this.postDataPramas.data = []
  937. this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': selectMonth }}
  938. this.postDataPramas.data[0].children = []
  939. this.postDataPramas.data[0].children[0] = { 'name': 'CopySevicplan', 'type': 'e', 'parammaps': {
  940. pastureName: this.getdataListParm.parammaps.pastureName,
  941. eqName: this.getdataListParm.parammaps.eqName,
  942. eqCode: this.getdataListParm.parammaps.eqCode,
  943. typeCode: this.getdataListParm.parammaps.typeCode,
  944. departmentId: this.getdataListParm.parammaps.departmentId,
  945. monthIN: this.getdataListParm.month,
  946. NewmonthIN: '@insertSpotList.NewmonthIN'
  947. }}
  948. ExecDataByConfig(this.postDataPramas).then(response => {
  949. console.log('复制保存发送参数', this.postDataPramas)
  950. if (response.msg !== 'fail') {
  951. this.dialogFormVisibleCopy = false
  952. this.$notify({
  953. title: '成功',
  954. message: '复制成功',
  955. type: 'success',
  956. duration: 2000
  957. })
  958. } else {
  959. failproccess(response, this.$notify)
  960. }
  961. })
  962. }
  963. },
  964. handleDelate() {
  965. MessageBox.confirm('是否清空本月保养计划?', {
  966. confirmButtonText: '确认',
  967. cancelButtonText: '取消',
  968. type: 'warning'
  969. }).then(() => {
  970. this.requestParam.name = 'ClearSevicplan'
  971. this.requestParam.parammaps = {}
  972. this.requestParam.parammaps.pastureName = this.getdataListParm.parammaps.pastureName
  973. this.requestParam.parammaps.eqName = this.getdataListParm.parammaps.eqName
  974. this.requestParam.parammaps.eqCode = this.getdataListParm.parammaps.eqCode
  975. this.requestParam.parammaps.typeCode = this.getdataListParm.parammaps.typeCode
  976. this.requestParam.parammaps.departmentId = this.getdataListParm.parammaps.departmentId
  977. this.requestParam.parammaps.monthIN = this.getdataListParm.month
  978. PostDataByName(this.requestParam).then(() => {
  979. this.getList()
  980. this.dialogFormVisible = false
  981. this.$notify({
  982. title: '成功',
  983. message: '清空成功',
  984. type: 'success',
  985. duration: 2000
  986. })
  987. })
  988. }).catch(() => {
  989. this.$message({
  990. type: 'info',
  991. message: '已取消清空'
  992. })
  993. })
  994. },
  995. beforeImportExcel(file) {
  996. const isLt2M = file.size / 1024 / 1024 < 10
  997. if (!isLt2M) {
  998. this.$message.error('上传文件大小不能超过 10MB!')
  999. }
  1000. return isLt2M
  1001. },
  1002. handleImportExcelSuccess(res, file) {
  1003. if (res.msg === 'ok') {
  1004. this.$message({
  1005. title: '成功',
  1006. message: '导入成功:' + res.data.success + '条!',
  1007. type: 'success',
  1008. duration: 2000
  1009. })
  1010. if (res.data.err_count > 0) {
  1011. this.$notify({
  1012. title: '失败',
  1013. message: '导入失败:' + res.data.err_count + '条!',
  1014. type: 'danger',
  1015. duration: 2000
  1016. })
  1017. import('@/vendor/Export2Excel').then(excel => {
  1018. const list1 = res.data.result
  1019. const tHeader = [
  1020. '月份', '部门名称', '编码', '资产名称', '牧场', '保养人', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', 'error_msg'
  1021. ]
  1022. const filterVal = [
  1023. '月份', '部门名称', '编码', '资产名称', '牧场', '保养人', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', 'error_msg'
  1024. ]
  1025. const data1 = this.formatJson(filterVal, list1)
  1026. excel.export_json_to_excel({
  1027. header: tHeader,
  1028. data: data1,
  1029. filename: '保养计划',
  1030. autoWidth: true,
  1031. bookType: 'xlsx'
  1032. })
  1033. })
  1034. }
  1035. } else {
  1036. this.$notify({
  1037. title: '失败',
  1038. message: '上传失败',
  1039. type: 'danger',
  1040. duration: 2000
  1041. })
  1042. }
  1043. },
  1044. formatJson(filterVal, jsonData) {
  1045. return jsonData.map(v =>
  1046. filterVal.map(j => {
  1047. if (j === 'timestamp') {
  1048. return parseTime(v[j])
  1049. } else {
  1050. return v[j]
  1051. }
  1052. })
  1053. )
  1054. },
  1055. handleDownloadTemp() {
  1056. this.downLoadParm = {}
  1057. this.downLoadParm.name = 'getUpkeepeqlist'
  1058. this.downLoadParm.month = this.getdataListParm.month
  1059. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  1060. GetDataByName(this.downLoadParm).then(response => {
  1061. if (response.data.list !== null) {
  1062. this.downloadList = response.data.list
  1063. } else {
  1064. this.downloadList = []
  1065. }
  1066. var temp = this.downLoadParm.month.split('-')
  1067. var year = temp[0]
  1068. var month = temp[1]
  1069. var d = new Date(year, month, 0)
  1070. var tHeader = ['月份', '部门名称', '编码', '资产名称', '牧场', '保养人']
  1071. for (let index = 1; index <= d.getDate(); index++) {
  1072. // eslint-disable-next-line no-undef
  1073. index = JSON.stringify(index)
  1074. var m = { 'label': index, 'column_name': 'm' + index, 'width': '40' }
  1075. // table.push(m)
  1076. tHeader.push(index)
  1077. }
  1078. console.log(tHeader, '====')
  1079. // return
  1080. const elecExcelDatas = [
  1081. {
  1082. tHeader: tHeader,
  1083. filterVal: ['i', 'name', 'deptName', 'eqName', 'eqCode', 'brandname'],
  1084. // tableDatas: this.downloadList,
  1085. tableDatas: [],
  1086. sheetName: 'SheetJS'
  1087. }
  1088. ]
  1089. json2excel(elecExcelDatas, '保养计划模板', true, 'xlsx')
  1090. })
  1091. },
  1092. handleDownload() {
  1093. this.$alert('保养计划正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  1094. this.isPercentage = true
  1095. this.percentage = 1
  1096. var timer = setInterval(() => {
  1097. this.percentage += 5
  1098. if (this.percentage > 95) {
  1099. this.percentage = 99
  1100. clearInterval(timer)
  1101. }
  1102. this.percentage = this.percentage
  1103. }, 1000)
  1104. this.getdataListParmSH.month = this.getdataListParm.month
  1105. this.getdataListParmSH.parammaps = this.getdataListParm.parammaps
  1106. GetUpkeepPlan(this.getdataListParmSH).then(response => {
  1107. this.downLoadList = response.data.list
  1108. if (response.data.list !== '') {
  1109. this.percentage = 99
  1110. setTimeout(() => {
  1111. this.isPercentage = false
  1112. }, 2000)
  1113. }
  1114. console.log('ssssss',this.downLoadList)
  1115. var temp = this.getdataListParmSH.month.split('-')
  1116. var year = temp[0]
  1117. var month = temp[1]
  1118. var d = new Date(year, month, 0)
  1119. var tHeader = ['月份', '部门名称', '编码', '资产名称', '牧场', '保养人','1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
  1120. this.downLoadList.forEach(row => {
  1121. row.m1 = (typeof row.m1 === 'undefined') ? '' : row.m1.substr(0,1)
  1122. row.m2 = (typeof row.m2 === 'undefined') ? '' : row.m2.substr(0,1)
  1123. row.m3 = (typeof row.m3 === 'undefined') ? '' : row.m3.substr(0,1)
  1124. row.m4 = (typeof row.m4 === 'undefined') ? '' : row.m4.substr(0,1)
  1125. row.m5 = (typeof row.m5 === 'undefined') ? '' : row.m5.substr(0,1)
  1126. row.m6 = (typeof row.m6 === 'undefined') ? '' : row.m6.substr(0,1)
  1127. row.m7 = (typeof row.m7 === 'undefined') ? '' : row.m7.substr(0,1)
  1128. row.m8 = (typeof row.m8 === 'undefined') ? '' : row.m8.substr(0,1)
  1129. row.m9 = (typeof row.m9 === 'undefined') ? '' : row.m9.substr(0,1)
  1130. row.m10 = (typeof row.m10 === 'undefined') ? '' : row.m10.substr(0,1)
  1131. row.m11 = (typeof row.m11 === 'undefined') ? '' : row.m11.substr(0,1)
  1132. row.m12 = (typeof row.m12 === 'undefined') ? '' : row.m12.substr(0,1)
  1133. row.m13 = (typeof row.m13 === 'undefined') ? '' : row.m13.substr(0,1)
  1134. row.m14 = (typeof row.m14 === 'undefined') ? '' : row.m14.substr(0,1)
  1135. row.m15 = (typeof row.m15 === 'undefined') ? '' : row.m15.substr(0,1)
  1136. row.m16 = (typeof row.m16 === 'undefined') ? '' : row.m16.substr(0,1)
  1137. row.m17 = (typeof row.m17 === 'undefined') ? '' : row.m17.substr(0,1)
  1138. row.m18 = (typeof row.m18 === 'undefined') ? '' : row.m18.substr(0,1)
  1139. row.m19 = (typeof row.m19 === 'undefined') ? '' : row.m19.substr(0,1)
  1140. row.m20 = (typeof row.m20 === 'undefined') ? '' : row.m20.substr(0,1)
  1141. row.m21 = (typeof row.m21 === 'undefined') ? '' : row.m21.substr(0,1)
  1142. row.m22 = (typeof row.m22 === 'undefined') ? '' : row.m22.substr(0,1)
  1143. row.m23 = (typeof row.m23 === 'undefined') ? '' : row.m23.substr(0,1)
  1144. row.m24 = (typeof row.m24 === 'undefined') ? '' : row.m24.substr(0,1)
  1145. row.m25 = (typeof row.m25 === 'undefined') ? '' : row.m25.substr(0,1)
  1146. row.m26 = (typeof row.m26 === 'undefined') ? '' : row.m26.substr(0,1)
  1147. row.m27 = (typeof row.m27 === 'undefined') ? '' : row.m27.substr(0,1)
  1148. row.m28 = (typeof row.m28 === 'undefined') ? '' : row.m28.substr(0,1)
  1149. row.m29 = (typeof row.m29 === 'undefined') ? '' : row.m29.substr(0,1)
  1150. row.m30 = (typeof row.m30 === 'undefined') ? '' : row.m30.substr(0,1)
  1151. row.m31 = (typeof row.m31 === 'undefined') ? '' : row.m31.substr(0,1)
  1152. });
  1153. const elecExcelDatas = [
  1154. {
  1155. tHeader: tHeader,
  1156. filterVal: ['month','deptName','eqCode','eqName','pastureName','employeName','m1','m2','m3','m4','m5','m6','m7','m8','m9','m10','m11','m12','m13','m14','m15','m16','m17','m18','m19','m20','m21','m22','m23','m24','m25','m26','m27','m28','m29','m30','m31'],
  1157. tableDatas: this.downLoadList,
  1158. sheetName: 'SheetJS'
  1159. }
  1160. ]
  1161. json2excel(elecExcelDatas, '保养计划', true, 'xlsx')
  1162. })
  1163. },
  1164. }
  1165. }
  1166. </script>
  1167. <style lang="scss">
  1168. .el-input--small .el-input__inner{
  1169. height: 38px !important;
  1170. }
  1171. </style>