index.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" @change="changePastureName">
  5. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  6. </el-select>
  7. <el-select v-model="getdataListParm.parammaps.departmentName" clearable placeholder="部门" class="filter-item">
  8. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
  9. </el-select>
  10. <el-autocomplete ref="cardNumber" v-model="getdataListParm.parammaps.cardNumber" style="width:300px" value-key="cardNumber" class="inline-input filter-item" :fetch-suggestions="cardNumberSearch" placeholder="请选择油卡编号" @select="handlecardNumberSelect">
  11. <template slot-scope="{ item }">
  12. <div class="name" style="display: inline;">{{ item.cardNumber }}</div>
  13. </template>
  14. </el-autocomplete>
  15. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  16. <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
  17. <el-button class="filter-item" style="margin-left: 10px;display: inline-block;" type="info" icon="el-icon-tickets" @click="handleDownloadTemp"> 模板 </el-button>
  18. <el-button v-if="isOtherinfoExport" class="filter-item" type="success" style="margin-left: 10px;" icon="el-icon-download" @click="handleDownload">导出</el-button>
  19. <el-upload :headers="headers" style="margin-left: 10px;display: inline-block;" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
  20. <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
  21. </el-upload>
  22. </div>
  23. <el-table
  24. :key="tableKey"
  25. v-loading="listLoading"
  26. element-loading-text="给我一点时间"
  27. :data="list"
  28. border
  29. fit
  30. highlight-current-row
  31. style="width: 100%;"
  32. :row-style="rowStyle"
  33. :cell-style="cellStyle"
  34. class="elTable"
  35. @sort-change="tableSort"
  36. >
  37. <el-table-column label="序号" align="center" type="index" width="50px">
  38. <template slot-scope="scope">
  39. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="部门" min-width="110px" align="center" prop="departmentName" />
  43. <el-table-column label="油卡编号" min-width="110px" align="center" prop="cardNumber" />
  44. <el-table-column label="油卡类型" min-width="110px" align="center" prop="cardType" />
  45. <el-table-column label="剩余余额" min-width="110px" align="center" sortable prop="cardAmount" />
  46. <el-table-column label="设备编号" min-width="110px" align="center" prop="assetNumber" />
  47. <el-table-column label="设备名称" min-width="110px" align="center" prop="assetName" />
  48. <el-table-column label="油卡状态" min-width="110px" align="center" prop="assetName">
  49. <template slot-scope="scope">
  50. <span v-if="scope.row.enable == 0">启用</span>
  51. <span v-else>停用</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="操作" align="center" width="350" class-name="small-padding fixed-width" fixed="right">
  55. <template slot-scope="{row}">
  56. <el-button v-if="row.enable == 0" type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  57. <el-button type="success" size="mini" @click="handleChange(row)">变更记录</el-button>
  58. <el-button type="success" size="mini" @click="handleRecharge(row)">充值</el-button>
  59. <el-button v-if="row.enable == 0" type="danger" size="mini" @click="handleDisable(row)">停用</el-button>
  60. <el-button v-else type="danger" size="mini" @click="handleDisable(row)">启用</el-button>
  61. <el-button v-if="row.enable == 1" type="danger" size="mini" @click="form_delete(row)">删除</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  66. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="50%">
  67. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="100px" style="width: 800px; margin-left:50px;">
  68. <el-row>
  69. <el-col :span="12">
  70. <el-form-item label="卡号:" prop="cardNumber">
  71. <el-input ref="cardNumber" v-model="temp.cardNumber" :disabled="dialogStatus=='update'" />
  72. </el-form-item>
  73. </el-col>
  74. </el-row>
  75. <el-row>
  76. <el-col :span="12">
  77. <el-form-item label="设备:" prop="assetSum">
  78. <el-autocomplete ref="assetSum" v-model="temp.assetSum" style="width:300px" value-key="assetSum" class="inline-input" :fetch-suggestions="formNumberSearch" placeholder="请选择设备" @select="handleformNameSelect" @blur="blurformNameSelect">
  79. <template slot-scope="{ item }">
  80. <div class="name" style="display: inline;">{{ item.assetName }}</div>
  81. </template>
  82. </el-autocomplete>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. <el-row>
  87. <el-col :span="12">
  88. <el-form-item label="牧场:" prop="pastureName">
  89. <el-input ref="pastureName" v-model="temp.pastureName" disabled />
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row>
  94. <el-col :span="12">
  95. <el-form-item label="部门:" prop="departmentName">
  96. <el-input ref="departmentName" v-model="temp.departmentName" disabled />
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row>
  101. <el-col :span="12">
  102. <el-form-item label="卡类型:" prop="cardType">
  103. <el-select ref="cardType" v-model="temp.cardType" placeholder="卡类型" style="width:100%;">
  104. <el-option v-for="item in cardTypeList" :key="item.id" :label="item.name" :value="item.name" />
  105. </el-select>
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="12">
  111. <el-form-item label="卡余额:" prop="cardAmount">
  112. <el-input ref="cardAmount" v-model="temp.cardAmount" />
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. </el-form>
  117. <div slot="footer" class="dialog-footer">
  118. <el-button v-if="dialogStatus==='create'" ref="createb" :disabled="isokDisable" type="success" @click="add_dialog_save_again()">保存并新增</el-button>
  119. <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  120. <el-button @click="dialogFormVisible = false;getList()">取消并关闭</el-button>
  121. </div>
  122. </el-dialog>
  123. <el-dialog :title="textMap[tabledialogStatus]" :visible.sync="changeFormVisible" :close-on-click-modal="false" width="50%">
  124. <el-table
  125. :key="tableKey"
  126. v-loading="changelistLoading"
  127. element-loading-text="给我一点时间"
  128. :data="changelist"
  129. border
  130. fit
  131. highlight-current-row
  132. style="width: 100%;"
  133. :row-style="rowStyle"
  134. :cell-style="cellStyle"
  135. class="elTable"
  136. >
  137. <el-table-column label="变更日期" align="center" sortable min-width="110px" prop="changeDate" />
  138. <el-table-column label="变更类型" align="center" min-width="110px" prop="changeType" />
  139. <el-table-column label="变更前设备" align="center" min-width="110px" prop="beforeMaintenance" />
  140. <el-table-column label="变更后设备" align="center" min-width="110px" prop="afterMaintenance" />
  141. <el-table-column label="变更人" align="center" min-width="110px" prop="empname" />
  142. </el-table>
  143. <h3 style="font-weight: 300;">{{ cardNumber }}-启停记录</h3>
  144. <el-table
  145. :key="tableKey2"
  146. v-loading="changelistLoading"
  147. element-loading-text="给我一点时间"
  148. :data="changelist2"
  149. border
  150. fit
  151. highlight-current-row
  152. style="width: 100%;"
  153. :row-style="rowStyle"
  154. :cell-style="cellStyle"
  155. class="elTable"
  156. >
  157. <el-table-column label="启停日期" align="center" sortable min-width="110px" prop="oildCardDate" />
  158. <el-table-column label="启停类型" align="center" min-width="110px" prop="statue" />
  159. <el-table-column label="操作人" align="center" min-width="110px" prop="personName" />
  160. </el-table>
  161. <div slot="footer" class="dialog-footer" style="bottom:10px">
  162. <el-button @click="changeFormVisible = false;getList()">关闭</el-button>
  163. </div>
  164. </el-dialog>
  165. <el-dialog :title="textMap[tabledialogStatus]" :visible.sync="rechargeFormVisible" :close-on-click-modal="false" width="50%">
  166. <el-table
  167. :key="tableKey"
  168. v-loading="rechargelistLoading"
  169. element-loading-text="给我一点时间"
  170. :data="rechargelist"
  171. border
  172. fit
  173. highlight-current-row
  174. style="width: 100%;"
  175. :row-style="rowStyle"
  176. :cell-style="cellStyle"
  177. class="elTable"
  178. >
  179. <el-table-column label="日期" align="center" type="index" width="150px">
  180. <template slot-scope="scope">
  181. <span>{{ scope.row.dateFormat }}</span>
  182. </template>
  183. </el-table-column>
  184. <el-table-column label="卡号" min-width="110px" align="center">
  185. <template slot-scope="scope">
  186. <span>{{ scope.row.cardCode }}</span>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="充值金额" width="150px" align="center">
  190. <template slot-scope="scope">
  191. <span>{{ scope.row.rechargeNum }}</span>
  192. </template>
  193. </el-table-column>
  194. <el-table-column label="充值人" width="150px" align="center">
  195. <template slot-scope="scope">
  196. <span>{{ scope.row.empName }}</span>
  197. </template>
  198. </el-table-column>
  199. </el-table>
  200. <div slot="footer" class="dialog-footer" style="bottom:10px">
  201. <el-button v-if="rechargeTemp.enable == 0" type="success" @click="createRecharge()">充值</el-button>
  202. <el-button @click="rechargeFormVisible = false;getList()">取消并关闭</el-button>
  203. </div>
  204. </el-dialog>
  205. <el-dialog :title="textMap[dialogStatus]" :visible.sync="rechargeFFormVisible" :close-on-click-modal="false" width="50%">
  206. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="100px" style="width: 800px; margin-left:50px;">
  207. <el-row>
  208. <el-col :span="8">
  209. <el-form-item label="负责人:" prop="employeId">
  210. <el-select v-model="temp.employeId" placeholder="负责人" class="filter-item" style="width:100%;">
  211. <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.id" />
  212. </el-select>
  213. </el-form-item>
  214. </el-col>
  215. </el-row>
  216. <el-row>
  217. <el-col :span="8">
  218. <el-form-item label="当前时间:" prop="dateFormat" style="width:100%;">
  219. <el-date-picker v-model="temp.dateFormat" type="date" placeholder="当前时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd" disabled style="width:100%;" />
  220. </el-form-item>
  221. </el-col>
  222. </el-row>
  223. <el-row>
  224. <el-col :span="8">
  225. <el-form-item label="充值金额" prop="rechargeNum" style="width:100%;">
  226. <el-input ref="rechargeNum" v-model="temp.rechargeNum" />
  227. </el-form-item>
  228. </el-col>
  229. </el-row>
  230. </el-form>
  231. <div slot="footer" class="dialog-footer">
  232. <el-button type="primary" @click="createRechargeData()">确认</el-button>
  233. <el-button @click="rechargeFFormVisible = false">取消并关闭</el-button>
  234. </div>
  235. </el-dialog>
  236. </div>
  237. </template>
  238. <script>
  239. // 引入
  240. import { GetDataByName, GetDataByNames, PostDataByName, getRecuData, ExecDataByConfig, failproccess,checkButtons } from '@/api/common'
  241. import waves from '@/directive/waves'
  242. import { parseTime, sortChange,json2excel } from '@/utils/index.js'
  243. import { validateEMail } from '@/utils/validate.js'
  244. import Pagination from '@/components/Pagination'
  245. import { MessageBox } from 'element-ui'
  246. import Cookies from 'js-cookie'
  247. import { getToken } from '@/utils/auth'
  248. export default {
  249. name: 'Otherinfo',
  250. components: { Pagination },
  251. directives: { waves },
  252. data() {
  253. return {
  254. isOtherinfoExport:[],
  255. buttons:[],
  256. isokDisable: false,
  257. tableKey: 0,
  258. tableKey2: 0,
  259. list: null,
  260. changelist: null,
  261. changelist2: null,
  262. rechargelist: null,
  263. total: 0,
  264. listLoading: true,
  265. changelistLoading: true,
  266. rechargelistLoading: true,
  267. formNumberSearchList: [],
  268. requestParam: {
  269. name: 'insertAsset',
  270. offset: 0,
  271. pagecount: 0,
  272. parammaps: {}
  273. },
  274. requestParam2: {},
  275. parentDept: [],
  276. getDeptParm: { name: 'getdeptrecu', idname: 'value', params: [-1] },
  277. postDataPramas: { },
  278. getdataListParm: {
  279. name: 'getOilcardList', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  280. parammaps: { pname: '', pastureName: Cookies.get('pasturename') }
  281. },
  282. requestFilterParams: {
  283. name: '', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  284. parammaps: {}
  285. },
  286. requestFilterParams2: {
  287. name: '', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  288. parammaps: {}
  289. },
  290. getchangedataListParm: {
  291. name: 'getOilcardHistory', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  292. parammaps: { }
  293. },
  294. getchangedataListParm2: {
  295. // name: 'getOilcardHistory', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  296. // parammaps: { }
  297. },
  298. getrechargedataListParm: {
  299. name: 'getrechargerecordList', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  300. parammaps: { }
  301. },
  302. cardTypeList: [{ name: 'IC卡', id: '0' }, { name: '磁卡', id: '1' }],
  303. findAllProvider: [],
  304. findAllAssetType: [],
  305. findAllPasture: [],
  306. findAllDepart: [],
  307. findAllEmploye: [],
  308. getDictByName: [],
  309. findAllAsset: [],
  310. requestParams: [
  311. { name: 'findAllProvider', offset: 0, pagecount: 0, params: [] },
  312. { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
  313. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  314. // { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  315. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  316. { name: 'findAllAsset', offset: 0, pagecount: 0, params: [] },
  317. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] }
  318. ],
  319. getDepartParam: { name: 'findAllDepart1', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid'), 'eId': Cookies.get('employeid') }},
  320. dataform: { deptId: '', parentId: '' },
  321. temp: {},
  322. dialogFormVisible: false,
  323. changeFormVisible: false,
  324. rechargeFormVisible: false,
  325. rechargeFFormVisible: false,
  326. tabledialogStatus: '',
  327. dialogStatus: '',
  328. textMap: { update: '编辑', create: '新增', change: '变更记录', recharge: '充值记录', changeF: '换卡', rechargeF: '充值' },
  329. dialogPvVisible: false,
  330. // 校验规则
  331. rules: {
  332. cardNumber: [{ required: true, message: '必填', trigger: 'blur' }],
  333. cardType: [{ required: true, message: '必填', trigger: 'blur' }],
  334. cardAmount: [{ required: true, message: '必填', trigger: 'blur' }]
  335. },
  336. rechargeTemp: {},
  337. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  338. cellStyle: { padding: 0 + 'px' },
  339. defaultProps: {
  340. children: 'children',
  341. label: 'label'
  342. },
  343. nodeKey: 'value',
  344. defaultCheckedKeys: [],
  345. cardNumber: '',
  346. isPercentage: false,
  347. percentage: 1,
  348. downLoadParm:{},
  349. downLoadList:[]
  350. }
  351. },
  352. computed: {
  353. // 设置请求头
  354. headers() {
  355. return {
  356. token: getToken()
  357. }
  358. },
  359. uploadData() {
  360. return {
  361. name: 'importOilcard',
  362. importParams: '牧场,车自编号,油卡,类型,上次用油量,部门',
  363. sheetname: 'SheetJS'
  364. }
  365. },
  366. // 设置上传地址
  367. uploadExcelUrl() {
  368. // process.env.VUE_APP_BASE_API是服务器的路径,也是axios的基本路径
  369. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  370. }
  371. },
  372. created() {
  373. const that = this
  374. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  375. that.buttons = response.data.list
  376. that.getButtons()
  377. })
  378. this.getDownList()
  379. this.getList()
  380. this.getDepartDownList()
  381. },
  382. methods: {
  383. getButtons() {
  384. // 导出
  385. const OtherinfoExport = 'basic:otherinfo:otherinfoExport'
  386. const isOtherinfoExport = checkButtons(this.buttons, OtherinfoExport)
  387. this.isOtherinfoExport = isOtherinfoExport
  388. },
  389. tableSort(column) {
  390. sortChange(column, this.list)
  391. },
  392. getDeptList() {
  393. getRecuData(this.getDeptParm).then(response => {
  394. this.parentDept = response.data
  395. })
  396. },
  397. popoverHide(checkedIds, checkedData) {
  398. this.dataform.deptId = checkedIds
  399. this.dataform.parentId = checkedData.parentid
  400. },
  401. providerSearch(queryString, cb) {
  402. var returnList = this.findAllProvider
  403. var results = queryString
  404. ? returnList.filter(this.createFilter(queryString))
  405. : returnList
  406. // 调用 callback 返回建议列表的数据
  407. cb(results)
  408. },
  409. createFilter(queryString) {
  410. return returnValue => {
  411. return (
  412. returnValue.assetName.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
  413. )
  414. }
  415. },
  416. handleSelect(item) {
  417. console.log(item)
  418. },
  419. getList() {
  420. this.listLoading = true
  421. GetDataByName(this.getdataListParm).then(response => {
  422. if (response.data.list !== null) {
  423. for (let i = 0; i < response.data.list.length; i++) {
  424. if (response.data.list[i].cardAmount !== undefined) {
  425. this.$set(response.data.list[i], 'cardAmount', parseFloat(response.data.list[i].cardAmount))
  426. }
  427. }
  428. this.list = response.data.list
  429. this.pageNum = response.data.pageNum
  430. this.pageSize = response.data.pageSize
  431. } else {
  432. this.list = []
  433. this.pageNum = 0
  434. this.pageSize = 0
  435. }
  436. this.total = response.data.total
  437. this.getDeptList()
  438. setTimeout(() => {
  439. this.listLoading = false
  440. }, 100)
  441. })
  442. },
  443. getDownList() {
  444. this.requestParams[5].params[0] = this.$store.state.user.pastureid
  445. GetDataByNames(this.requestParams).then(response => {
  446. this.findAllProvider = response.data.findAllProvider.list
  447. this.findAllAssetType = response.data.findAllAssetType.list
  448. this.findAllPasture = response.data.findAllPasture.list
  449. // this.findAllDepart = response.data.findAllDepart.list
  450. this.findAllEmploye = response.data.findAllEmploye.list
  451. this.findAllAsset = response.data.findAllAsset.list
  452. this.getDictByName = response.data.getDictByName.list
  453. })
  454. },
  455. changePastureName(item) {
  456. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  457. this.getdataListParm.parammaps.departmentId = ''
  458. this.getDepartDownList()
  459. },
  460. getDepartDownList() {
  461. GetDataByName(this.getDepartParam).then(response => {
  462. this.findAllDepart = response.data.list
  463. })
  464. },
  465. form_search() {
  466. this.listLoading = true
  467. this.getdataListParm.offset = 1
  468. this.getList()
  469. },
  470. handleModifyStatus(row, status) {
  471. this.$message({ message: '操作成功', type: 'success' })
  472. row.status = status
  473. },
  474. form_reset() {
  475. this.temp = { inputDatetime: parseTime(new Date(), '{y}-{m}-{d}'), dateFormat: parseTime(new Date(), '{y}-{m}-{d}'), assetName: '', assetId: '', deptName: '', pastureName: '', pastureId: Cookies.get('pastureid'), cardNumber: '', cardType: '', cardAmount: '', rechargeNum: '' }
  476. },
  477. form_add() {
  478. this.form_reset()
  479. this.dialogStatus = 'create'
  480. this.dialogFormVisible = true
  481. this.$nextTick(() => {
  482. this.$refs['temp'].clearValidate()
  483. })
  484. },
  485. add_dialog_save() {
  486. this.$refs['temp'].validate(valid => {
  487. if (valid) {
  488. // 卡余额
  489. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  490. console.log(this.requestParam, '000')
  491. this.requestParam = {}
  492. this.requestParam.common = { 'returnmap': '0' }
  493. this.requestParam.data = []
  494. if (this.temp.departmentId == undefined || this.temp.departmentId == '') {
  495. this.temp.departmentId = ''
  496. this.temp.departmentName = ''
  497. }
  498. if (this.temp.assetId == undefined || this.temp.assetId == '') {
  499. this.temp.assetId = ''
  500. this.temp.assetSum = ''
  501. }
  502. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  503. this.temp.pastureName = Cookies.get('pasturename')
  504. }
  505. this.requestParam.data[0] = { 'name': 'checkOilcard', 'type': 'v', 'parammaps': {
  506. cardCode: this.temp.cardNumber,
  507. eqId: this.temp.assetId
  508. }}
  509. this.requestParam.data[1] = { 'name': 'insertOilcard', 'type': 'e', 'parammaps': {
  510. assetId: this.temp.assetId,
  511. assetName: this.temp.assetSum,
  512. cardAmount: this.temp.cardAmount,
  513. cardNumber: this.temp.cardNumber,
  514. cardType: this.temp.cardType,
  515. dateFormat: this.temp.dateFormat,
  516. departmentId: this.temp.departmentId,
  517. deptName: this.temp.departmentName,
  518. inputDatetime: this.temp.inputDatetime,
  519. pastureId: this.temp.pastureId,
  520. pastureName: this.temp.pastureName,
  521. rechargeNum: this.temp.rechargeNum
  522. }}
  523. if (this.temp.assetSum !== null && this.temp.assetSum !== undefined && this.temp.assetSum !== '') {
  524. this.requestParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': [{ changeType: '新增', beforeMaintenance: 0, afterMaintenance: this.temp.assetSum, changePersonId: Cookies.get('employeid') }] }}
  525. this.requestParam.data[2].children = []
  526. this.requestParam.data[2].children[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  527. oildcardId: '@insertOilcard.LastInsertId',
  528. changeType: '@insertSpotList.changeType',
  529. beforeMaintenance: '@insertSpotList.beforeMaintenance',
  530. afterMaintenance: '@insertSpotList.afterMaintenance',
  531. changePersonId: '@insertSpotList.changePersonId'
  532. }}
  533. }
  534. ExecDataByConfig(this.requestParam).then(response => {
  535. if (response.msg === 'fail') {
  536. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  537. } else {
  538. this.getList()
  539. this.dialogFormVisible = false
  540. this.$notify({ title: '成功', message: '新增成功', type: 'success', duration: 2000 })
  541. }
  542. })
  543. }
  544. })
  545. },
  546. add_dialog_save_again() {
  547. this.$refs['temp'].validate(valid => {
  548. if (valid) {
  549. // 卡余额
  550. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  551. console.log(this.requestParam, '000')
  552. this.requestParam = {}
  553. this.requestParam.common = { 'returnmap': '0' }
  554. this.requestParam.data = []
  555. if (this.temp.departmentId == undefined || this.temp.departmentId == '') {
  556. this.temp.departmentId = ''
  557. this.temp.departmentName = ''
  558. }
  559. if (this.temp.assetId == undefined || this.temp.assetId == '') {
  560. this.temp.assetId = ''
  561. this.temp.assetSum = ''
  562. }
  563. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  564. this.temp.pastureName = Cookies.get('pasturename')
  565. }
  566. this.requestParam.data[0] = { 'name': 'checkOilcard', 'type': 'v', 'parammaps': {
  567. cardCode: this.temp.cardNumber,
  568. eqId: this.temp.assetId
  569. }}
  570. this.requestParam.data[1] = { 'name': 'insertOilcard', 'type': 'e', 'parammaps': {
  571. assetId: this.temp.assetId,
  572. assetName: this.temp.assetSum,
  573. cardAmount: this.temp.cardAmount,
  574. cardNumber: this.temp.cardNumber,
  575. cardType: this.temp.cardType,
  576. dateFormat: this.temp.dateFormat,
  577. departmentId: this.temp.departmentId,
  578. deptName: this.temp.departmentName,
  579. inputDatetime: this.temp.inputDatetime,
  580. pastureId: this.temp.pastureId,
  581. pastureName: this.temp.pastureName,
  582. rechargeNum: this.temp.rechargeNum
  583. }}
  584. if (this.temp.assetSum !== null && this.temp.assetSum !== undefined && this.temp.assetSum !== '') {
  585. this.requestParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': [{ changeType: '新增', beforeMaintenance: 0, afterMaintenance: this.temp.assetSum, changePersonId: Cookies.get('employeid') }] }}
  586. this.requestParam.data[2].children = []
  587. this.requestParam.data[2].children[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  588. oildcardId: '@insertOilcard.LastInsertId',
  589. changeType: '@insertSpotList.changeType',
  590. beforeMaintenance: '@insertSpotList.beforeMaintenance',
  591. afterMaintenance: '@insertSpotList.afterMaintenance',
  592. changePersonId: '@insertSpotList.changePersonId'
  593. }}
  594. }
  595. ExecDataByConfig(this.requestParam).then(response => {
  596. if (response.msg === 'fail') {
  597. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  598. } else {
  599. this.form_reset()
  600. this.$notify({ title: '成功', message: '新增成功', type: 'success', duration: 2000 })
  601. }
  602. })
  603. }
  604. })
  605. },
  606. createRechargeData() {
  607. this.$refs['temp'].validate(valid => {
  608. if (valid) {
  609. const rechargeNum = /^\d+(\.\d{1,2})?$/
  610. // 充值金额
  611. if (!rechargeNum.test(parseFloat(this.temp.rechargeNum))) {
  612. this.$message({ type: 'error', message: '充值金额请保留两位小数', duration: 2000 })
  613. return false
  614. }
  615. this.postDataPramas.common = { 'returnmap': '0' }
  616. this.postDataPramas.data = []
  617. this.postDataPramas.data[0] = { 'name': 'insertrechargerecord', 'type': 'e', 'parammaps': {
  618. 'id': this.temp.id,
  619. 'employeId': this.temp.employeId,
  620. 'cardCode': this.temp.cardCode,
  621. 'rechargeNum': this.temp.rechargeNum
  622. }}
  623. this.postDataPramas.data[1] = { 'name': 'updateCardbalanceExecData', 'type': 'e', 'parammaps': {
  624. 'id': this.temp.id,
  625. 'rechargeNum': this.temp.rechargeNum
  626. }}
  627. ExecDataByConfig(this.postDataPramas).then(response => {
  628. if (response.msg === 'fail') {
  629. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  630. } else {
  631. this.getList()
  632. this.getrechargedataListParmList()
  633. this.rechargeFFormVisible = false
  634. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  635. }
  636. })
  637. }
  638. })
  639. },
  640. createRecharge() {
  641. this.dialogStatus = 'recharge'
  642. this.rechargeFFormVisible = true
  643. this.$set(this.temp, 'employeId', parseFloat(Cookies.get('employeid')))
  644. this.$set(this.temp, 'rechargeNum', '')
  645. this.temp.id = this.$store.id
  646. this.temp.dateFormat = parseTime(new Date(), '{y}-{m}-{d}')
  647. this.temp.cardCode = this.$store.cardCode
  648. // this.$nextTick(() => {
  649. // this.$refs['temp'].clearValidate()
  650. // })
  651. },
  652. handleChange(row) {
  653. this.textMap.change = row.cardNumber + '-变更记录'
  654. this.cardNumber = row.cardNumber
  655. this.tabledialogStatus = 'change'
  656. this.changeFormVisible = true
  657. this.getchangedataListParm.parammaps['oildcardId'] = row.id
  658. this.temp.dateFormat = parseTime(new Date(), '{y}-{m}-{d}')
  659. // this.getchangedataListParmList()
  660. this.getchangedataListParmList2(row)
  661. },
  662. getchangedataListParmList2(row) {
  663. this.changelistLoading = true
  664. this.getchangedataListParm2 = {}
  665. this.getchangedataListParm2.common = { 'returnmap': '0' }
  666. this.getchangedataListParm2.data = []
  667. this.getchangedataListParm2.data[0] = { 'name': 'getOilcardstatuehistory', 'type': 'sm', 'parammaps': {
  668. id: row.id
  669. }}
  670. this.getchangedataListParm2.data[1] = { 'name': 'getOilcardHistory', 'type': 'sm', 'parammaps': {
  671. id: row.id
  672. }}
  673. ExecDataByConfig(this.getchangedataListParm2).then(response => {
  674. if (response.data[0].resultmaps !== null) {
  675. this.changelist2 = response.data[0].resultmaps
  676. } else {
  677. this.changelist2 = []
  678. }
  679. if (response.data[1].resultmaps !== null) {
  680. this.changelist = response.data[1].resultmaps
  681. } else {
  682. this.changelist = []
  683. }
  684. setTimeout(() => {
  685. this.changelistLoading = false
  686. }, 100)
  687. })
  688. // GetDataByName(this.getchangedataListParm2).then(response => {
  689. // if (response.data.list !== null) {
  690. // this.changelist2 = response.data.list
  691. // } else {
  692. // this.changelist2 = []
  693. // }
  694. // setTimeout(() => {
  695. // this.changelistLoading2 = false
  696. // }, 100)
  697. // })
  698. },
  699. handleRecharge(row) {
  700. this.rechargeTemp = Object.assign({}, row)
  701. this.tabledialogStatus = 'recharge'
  702. this.rechargeFormVisible = true
  703. this.rechargelistLoading = true
  704. this.getrechargedataListParm.parammaps['cardId'] = row.id
  705. this.$store.id = row.id
  706. this.$store.cardCode = row.cardNumber
  707. this.getrechargedataListParmList()
  708. },
  709. getrechargedataListParmList() {
  710. GetDataByName(this.getrechargedataListParm).then(response => {
  711. this.rechargelist = response.data.list
  712. setTimeout(() => {
  713. this.rechargelistLoading = false
  714. }, 100)
  715. })
  716. },
  717. form_edit(row) {
  718. this.temp = Object.assign({}, row) // copy obj
  719. this.dialogStatus = 'update'
  720. this.dialogFormVisible = true
  721. if (this.temp.assetId == '' || this.temp.assetId == undefined) {
  722. this.temp.pastureName = ''
  723. }
  724. this.$nextTick(() => {
  725. this.$refs['temp'].clearValidate()
  726. })
  727. },
  728. edit_dialog_save() {
  729. this.$refs['temp'].validate(valid => {
  730. if (valid) {
  731. // 卡余额
  732. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  733. this.requestParam = {}
  734. this.requestParam.common = { 'returnmap': '0' }
  735. this.requestParam.data = []
  736. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  737. this.temp.pastureName = Cookies.get('pasturename')
  738. }
  739. if (this.temp.assetSum == '' || this.temp.assetSum == null || this.temp.assetSum == undefined) {
  740. this.temp.pastureName = ''
  741. this.temp.deptName = ''
  742. this.temp.departmentId = ''
  743. this.temp.assetId = ''
  744. this.requestParam.data[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  745. changeType: '删除',
  746. beforeMaintenance: 1,
  747. afterMaintenance: this.temp.assetSum,
  748. changePersonId: Cookies.get('employeid'),
  749. oildcardId: this.temp.id,
  750. pastureId: this.temp.pastureId,
  751. pastureName: this.temp.pastureName
  752. }}
  753. } else {
  754. this.requestParam.data[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  755. changeType: '修改',
  756. beforeMaintenance: 1,
  757. afterMaintenance: this.temp.assetSum,
  758. changePersonId: Cookies.get('employeid'),
  759. oildcardId: this.temp.id,
  760. pastureId: this.temp.pastureId,
  761. pastureName: this.temp.pastureName
  762. }}
  763. }
  764. this.requestParam.data[1] = { 'name': 'updateOilcard', 'type': 'e', 'parammaps': {
  765. cardNumber: this.temp.cardNumber,
  766. cardType: this.temp.cardType,
  767. cardAmount: this.temp.cardAmount,
  768. assetId: this.temp.assetId,
  769. departmentId: this.temp.departmentId,
  770. id: this.temp.id,
  771. pastureId: this.temp.pastureId,
  772. pastureName: this.temp.pastureName
  773. }}
  774. ExecDataByConfig(this.requestParam).then(response => {
  775. if (response.msg === 'fail') {
  776. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  777. } else {
  778. this.getList()
  779. this.dialogFormVisible = false
  780. this.$notify({ title: '成功', message: '修改成功', type: 'success', duration: 2000 })
  781. }
  782. })
  783. }
  784. })
  785. },
  786. handleDisable(row) {
  787. var statue = ''
  788. if (row.enable == 0) {
  789. statue = '停用'
  790. } else {
  791. statue = '启用'
  792. }
  793. var enable = ''
  794. if (row.enable == 0) {
  795. enable = '1'
  796. } else {
  797. enable = '0'
  798. }
  799. var aa = '确认' + statue + '?'
  800. MessageBox.confirm('油卡编号' + row.cardNumber, aa, { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
  801. this.requestParam = {}
  802. this.requestParam.common = { 'returnmap': '0' }
  803. this.requestParam.data = []
  804. this.requestParam.data[0] = { 'name': 'insertOilcardstatuehistory', 'type': 'e', 'parammaps': {
  805. oilCardId: row.id,
  806. statue: statue,
  807. personId: Cookies.get('employeid')
  808. }}
  809. this.requestParam.data[1] = { 'name': 'deleteOilcard', 'type': 'e', 'parammaps': {
  810. id: row.id,
  811. enable: enable
  812. }}
  813. console.log(this.requestParam)
  814. ExecDataByConfig(this.requestParam).then(response => {
  815. if (response.msg === 'fail') {
  816. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  817. } else {
  818. this.getList()
  819. this.dialogFormVisible = false
  820. this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
  821. }
  822. })
  823. }).catch(() => {
  824. this.$message({ type: 'info', message: '已取消停用' })
  825. })
  826. },
  827. form_delete(row) {
  828. MessageBox.confirm('油卡编号' + row.cardNumber, '确认删除?', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
  829. this.requestParam = {}
  830. this.requestParam.name = 'checkDeleteOilcard'
  831. this.requestParam.type = 'v'
  832. this.requestParam.parammaps = {}
  833. this.requestParam.parammaps.id = row.id
  834. ExecDataByConfig(this.requestParam).then((response) => {
  835. console.log(response)
  836. if (response.data == '成功执行!') {
  837. this.requestParam2.name = 'deleteOilcard2'
  838. this.requestParam2.parammaps = {}
  839. this.requestParam2.parammaps['id'] = row.id
  840. PostDataByName(this.requestParam2).then((response) => {
  841. if (response.msg == 'fail') {
  842. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  843. } else {
  844. this.getList()
  845. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  846. }
  847. })
  848. } else {
  849. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  850. }
  851. })
  852. }).catch(() => {
  853. this.$message({ type: 'info', message: '已取消删除' })
  854. })
  855. },
  856. handleformNameSelect(item) {
  857. console.log(item)
  858. this.temp.assetSum = item.assetName
  859. this.temp.assetId = item.assetId
  860. this.temp.departmentName = item.deptName
  861. this.temp.departmentId = item.departmentId
  862. this.temp.pastureId = item.pastureId
  863. this.temp.pastureName = item.pastureName
  864. },
  865. blurformNameSelect(item) {
  866. this.temp.assetSum = ''
  867. this.temp.assetId = ''
  868. this.temp.deptName = ''
  869. this.temp.departmentId = ''
  870. this.temp.departmentName = ''
  871. this.temp.pastureName = ''
  872. },
  873. formNumberSearch(queryString, cb) {
  874. this.requestFilterParams.name = 'findAssetM'
  875. this.requestFilterParams.parammaps['pastureId'] = Cookies.get('pastureid')
  876. this.requestFilterParams.parammaps['assetName'] = queryString
  877. GetDataByName(this.requestFilterParams).then(response => {
  878. if (response.data.list === null) {
  879. this.formNumberSearchList = []
  880. } else {
  881. this.formNumberSearchList = response.data.list
  882. }
  883. console.log(this.formNumberSearchList)
  884. console.log(this.formNumberSearchList[0])
  885. console.log('queryString', queryString)
  886. var results = queryString ? this.formNumberSearchList.filter(this.createFilter(queryString)) : this.formNumberSearchList
  887. cb(results)
  888. })
  889. },
  890. beforeImportExcel(file) {
  891. const isLt2M = file.size / 1024 / 1024 < 10
  892. if (!isLt2M) {
  893. this.$message.error('上传文件大小不能超过 10MB!')
  894. }
  895. return isLt2M
  896. },
  897. handleImportExcelSuccess(res, file) {
  898. this.getList()
  899. if (res.msg === 'ok') {
  900. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  901. if (res.data.err_count > 0) {
  902. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  903. import('@/vendor/Export2Excel').then(excel => {
  904. const list1 = res.data.result
  905. const tHeader = ['牧场', '车自编号', '油卡', '类型', '上次用油量', '部门', '错误信息']
  906. const filterVal = ['牧场', '车自编号', '油卡', '类型', '上次用油量', '部门', 'error_msg']
  907. const data1 = this.formatJson(filterVal, list1)
  908. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '油卡', autoWidth: true, bookType: 'xlsx' })
  909. })
  910. }
  911. } else {
  912. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  913. }
  914. },
  915. formatJson(filterVal, jsonData) {
  916. return jsonData.map(v =>
  917. filterVal.map(j => {
  918. if (j === 'timestamp') { return parseTime(v[j]) } else { return v[j] }
  919. })
  920. )
  921. },
  922. handleDownloadTemp() {
  923. import('@/vendor/Export2Excel').then(excel => {
  924. const list1 = []
  925. const tHeader = [
  926. '牧场', '车自编号', '油卡', '类型', '余额', '部门'
  927. ]
  928. const filterVal = [
  929. '牧场', '车自编号', '油卡', '类型', '余额', '部门'
  930. ]
  931. const data1 = this.formatJson(filterVal, list1)
  932. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '油卡模板', autoWidth: true, bookType: 'xlsx' })
  933. })
  934. },
  935. handlecardNumberSelect(item) {
  936. console.log(item)
  937. this.getdataListParm.parammaps.cardNumber = item.assetName
  938. },
  939. cardNumberSearch(queryString, cb) {
  940. this.requestFilterParams2.name = 'getOilcardList'
  941. this.requestFilterParams2.parammaps['cardNumber'] = queryString
  942. GetDataByName(this.requestFilterParams2).then(response => {
  943. if (response.data.list === null) {
  944. this.cardNumberSearchList = []
  945. } else {
  946. this.cardNumberSearchList = response.data.list
  947. }
  948. var results = queryString ? this.cardNumberSearchList.filter(this.createFilter(queryString)) : this.cardNumberSearchList
  949. cb(results)
  950. })
  951. },
  952. handleDownload() {
  953. this.$alert('油卡正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  954. this.isPercentage = true
  955. this.percentage = 1
  956. var timer = setInterval(() => {
  957. this.percentage += 5
  958. if (this.percentage > 95) {
  959. this.percentage = 99
  960. clearInterval(timer)
  961. }
  962. this.percentage = this.percentage
  963. }, 1000)
  964. this.downLoadParm.name = 'getOilcardList'
  965. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  966. GetDataByName(this.downLoadParm).then(response => {
  967. if(response.data.list !== null && response.data.list !== ''){
  968. for(let i=0;i<response.data.list.length;i++){
  969. if(response.data.list[i].enable == 0){
  970. this.$set(response.data.list[i],'enable','启用')
  971. }else{
  972. this.$set(response.data.list[i],'enable','停用')
  973. }
  974. }
  975. }
  976. this.downLoadList = response.data.list
  977. if (response.data.list !== '') {
  978. this.percentage = 99
  979. setTimeout(() => {
  980. this.isPercentage = false
  981. }, 2000)
  982. }
  983. console.log(this.downLoadList)
  984. const elecExcelDatas = [
  985. {
  986. tHeader: ['部门', '油卡编号', '油卡类型', '剩余余额', '设备编号', '设备名称', '油卡状态'],
  987. filterVal: ['departmentName', 'cardNumber', 'cardType', 'cardAmount', 'assetNumber', 'assetName', 'enable'],
  988. tableDatas: this.downLoadList,
  989. sheetName: '油卡'
  990. }
  991. ]
  992. json2excel(elecExcelDatas, '油卡', true, 'xlsx')
  993. })
  994. },
  995. }
  996. }
  997. </script>