index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
  4. <h4 style="padding-left: 10px;line-height: 0;">导出进度:</h4>
  5. <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
  6. </div>
  7. <div class="filter-container">
  8. <el-select ref="pastureName" v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" @change="changePastureName">
  9. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  10. </el-select>
  11. <el-input v-model="getdataListParm.parammaps.assetCode" placeholder="设备内部编号" clearable class="filter-item" style="width: 130px" />
  12. <el-input v-model="getdataListParm.parammaps.eqName" placeholder="设备名称" style="width: 130px;" class="filter-item" />
  13. <el-select v-model="getdataListParm.parammaps.departmentId" clearable placeholder="部门" class="filter-item" style="width: 100px">
  14. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-select v-model="getdataListParm.parammaps.status" clearable placeholder="状态" class="filter-item" style="width: 100px">
  17. <el-option v-for="item in getDictByName" :key="item.id" :label="item.label" :value="item.id" />
  18. </el-select>
  19. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  20. <div>
  21. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_add">变更</el-button>
  22. <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
  23. </div>
  24. </div>
  25. <el-table
  26. :key="tableKey"
  27. v-loading="listLoading"
  28. element-loading-text="给我一点时间"
  29. :data="list"
  30. border
  31. fit
  32. highlight-current-row
  33. style="width: 100%;"
  34. :row-style="rowStyle"
  35. :cell-style="cellStyle"
  36. class="elTable"
  37. >
  38. <!-- table表格 -->
  39. <el-table-column label="序号" align="center" type="index" width="50px">
  40. <template slot-scope="scope">
  41. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="牧场" min-width="110px" align="center">
  45. <template slot-scope="scope">
  46. <span>{{ scope.row.pastureName }}</span>
  47. </template>
  48. </el-table-column>
  49. <!-- <el-table-column label="资产编号" min-width="130px" align="center">
  50. <template slot-scope="scope">
  51. <span>{{ scope.row.assetCode }}</span>
  52. </template>
  53. </el-table-column> -->
  54. <el-table-column label="设备名称" min-width="110px" align="center">
  55. <template slot-scope="scope">
  56. <span>{{ scope.row.eqName }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="设备内部编号" min-width="110px" align="center">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.eqCode }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="规格" min-width="110px" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.specification }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="品牌" min-width="90px" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.brandName }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="设备图片" min-width="110px" align="center">
  75. <template slot-scope="scope">
  76. <el-popover placement="right" title="" trigger="hover">
  77. <img v-if="scope.row.picpath !== ''" :src="scope.row.picpath">
  78. <img v-if="scope.row.picpath !== ''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
  79. </el-popover>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="部门" width="90px" align="center">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.deptName }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="状态" min-width="80px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.status }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="变更日期" sortable prop="changeTime" min-width="110px" align="center" />
  93. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
  94. <template slot-scope="{row}">
  95. <el-button type="warning" size="mini" @click="form_edit(row)">状态变更</el-button>
  96. <el-button type="primary" size="mini" @click="form_see(row)">变更记录</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  101. <!-- 弹出层新增or修改 -->
  102. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
  103. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="140px">
  104. <el-row>
  105. <el-col :span="8">
  106. <el-form-item label="设备名称:" prop="assetName">
  107. <el-autocomplete
  108. ref="assetName"
  109. v-model="temp.assetName"
  110. value-key="assetName"
  111. class="inline-input"
  112. :fetch-suggestions="formNameSearch"
  113. placeholder="请输入内容"
  114. :disabled="dialogStatus==='update'"
  115. style="width:100%;"
  116. @select="handleformNameSelect"
  117. >
  118. <template slot-scope="{ item }">
  119. <div class="name" style="display: inline;">{{ item.eqName }}</div>
  120. <span class="addr">{{ item.eqCode }}</span>
  121. </template>
  122. </el-autocomplete>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="8">
  126. <el-form-item label="牧场设备编号:" prop="eqCode">
  127. <el-autocomplete
  128. ref="eqCode"
  129. v-model="temp.eqCode"
  130. value-key="eqCode"
  131. class="inline-input"
  132. :fetch-suggestions="formNumberSearch"
  133. placeholder="请输入内容"
  134. :disabled="dialogStatus==='update'"
  135. style="width:100%;"
  136. @select="handleformNumberSelect"
  137. >
  138. <template slot-scope="{ item }">
  139. <div class="name" style="display: inline;">{{ item.eqName }}</div>
  140. <span class="addr">{{ item.eqCode }}</span>
  141. </template>
  142. </el-autocomplete>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="8">
  146. <el-form-item label="变更状态:">
  147. <!-- <el-input v-model="temp.changeStatue" style="width:250px;" /> -->
  148. <el-select v-model="temp.status" clearable placeholder="状态" class="filter-item" style="width:100%;">
  149. <el-option v-for="item in getDictByName" :key="item.id" :label="item.label" :value="item.id" />
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. </el-row>
  154. <el-row>
  155. <el-col :span="8">
  156. <el-form-item label="牧场:">
  157. <!-- <span>{{ temp.pastureName }}</span> -->
  158. <el-input v-model="temp.pastureName" disabled style="width:100%;" />
  159. </el-form-item>
  160. </el-col>
  161. <el-col :span="8">
  162. <el-form-item label="部门:">
  163. <el-input v-model="temp.deptName" disabled style="width:100%;" />
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="8">
  167. <el-form-item label="变更时间:" prop="inputDatetime">
  168. <el-date-picker
  169. v-model="temp.inputDatetime"
  170. type="date"
  171. placeholder="变更时间"
  172. style="width:100%;"
  173. :picker-options="pickerOptions0"
  174. />
  175. </el-form-item>
  176. </el-col>
  177. </el-row>
  178. <el-row>
  179. <el-col :span="8">
  180. <el-form-item label="变更人:" prop="empId">
  181. <el-select v-model="temp.empId" placeholder="操作人" class="filter-item" style="width:100%;">
  182. <el-option
  183. v-for="item in findAllEmploye"
  184. :key="item.id"
  185. :label="item.name"
  186. :value="item.id"
  187. />
  188. </el-select>
  189. </el-form-item>
  190. </el-col>
  191. </el-row>
  192. </el-form>
  193. <div slot="footer" class="dialog-footer">
  194. <el-button type="primary" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">确认</el-button>
  195. <el-button @click="dialogFormVisible = false;getList()">关闭</el-button>
  196. </div>
  197. </el-dialog>
  198. <!-- 变更记录 -->
  199. <el-dialog :title="cardTitle" :visible.sync="dialogFormVisibleCard" :close-on-click-modal="false" width="90%">
  200. <div class="app-contentcard">
  201. <el-form ref="rowSeeData" :rules="rules" :model="rowSeeData" label-position="right" label-width="120px" style="width: 100%;margin:0 auto;">
  202. <div class="filter-container">
  203. <el-select
  204. v-model="getdataListParmSee.parammaps.changeStatue"
  205. clearable
  206. placeholder="状态"
  207. class="filter-item"
  208. style="width: 100px"
  209. >
  210. <el-option
  211. v-for="item in getDictByName"
  212. :key="item.id"
  213. :label="item.label"
  214. :value="item.id"
  215. />
  216. </el-select>
  217. <el-date-picker ref="inputDatetime2" v-model="getdataListParmSee.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 250px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
  218. <el-button
  219. v-waves
  220. class="filter-item"
  221. type="primary"
  222. icon="el-icon-search"
  223. @click="form_searchDelivery"
  224. >搜索</el-button>
  225. </div>
  226. </el-form>
  227. <el-table
  228. :key="tableKey"
  229. v-loading="listLoadingSee"
  230. element-loading-text="给我一点时间"
  231. :data="listSee"
  232. border
  233. fit
  234. highlight-current-row
  235. style="width: 100%;"
  236. :row-style="rowStyle"
  237. :cell-style="cellStyle"
  238. class="elTable"
  239. >
  240. <el-table-column label="序号" align="center" type="index" width="50px">
  241. <template slot-scope="scope">
  242. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="变更日期" sortable prop="changeTime" min-width="110px" align="center" />
  246. <el-table-column label="变更状态" min-width="110px" align="center">
  247. <template slot-scope="scope">
  248. <span>{{ scope.row.status }}</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="变更人" min-width="110px" align="center">
  252. <template slot-scope="scope">
  253. <span>{{ scope.row.empname }}</span>
  254. </template>
  255. </el-table-column>
  256. </el-table>
  257. <pagination
  258. v-show="totalSee>0"
  259. :total="totalSee"
  260. :page.sync="getdataListParmSee.offset"
  261. :limit.sync="getdataListParmSee.pagecount"
  262. @pagination="getListSee"
  263. />
  264. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:10px">
  265. <el-button @click="dialogFormVisibleCard = false">关闭</el-button>
  266. </div>
  267. </div>
  268. </el-dialog>
  269. </div>
  270. </template>
  271. <script>
  272. // 引入
  273. import { GetDataByName, GetDataByNames, ExecDataByConfig, GetAccount } from '@/api/common'
  274. import waves from '@/directive/waves' // waves directive
  275. import { parseTime } from '@/utils/index.js'
  276. // eslint-disable-next-line no-unused-vars
  277. import { validateEMail } from '@/utils/validate.js'
  278. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  279. // import { MessageBox } from 'element-ui'
  280. import Cookies from 'js-cookie'
  281. import { json2excel } from '@/utils/index.js'
  282. export default {
  283. name: 'Install',
  284. components: { Pagination },
  285. directives: { waves },
  286. data() {
  287. return {
  288. tableKey: 0,
  289. list: null,
  290. total: 0,
  291. listLoading: true,
  292. requestParam: {
  293. name: 'insertAsset',
  294. offset: 0,
  295. pagecount: 0,
  296. parammaps: {}
  297. },
  298. // 1-2:table&搜索传参
  299. getdataListParm: {
  300. name: 'geteqChangeList',
  301. page: 1,
  302. offset: 1,
  303. pagecount: 10,
  304. returntype: 'Map',
  305. parammaps: {
  306. assetCode: '',
  307. eqName: '',
  308. pastureName: Cookies.get('pasturename'),
  309. status: '',
  310. deptName: '',
  311. departmentId: ''
  312. }
  313. },
  314. downLoadParm: {},
  315. downLoadList: [],
  316. // 2-3:下拉框请求后数据加入[]
  317. findAllProvider: [],
  318. findAllAssetType: [],
  319. findAllPasture: [],
  320. findAllDepart: [],
  321. findAllEmploye: [],
  322. getDictByName: [],
  323. // 2-1.请求下拉框接口
  324. requestParams: [
  325. { name: 'findAllProvider', offset: 0, pagecount: 0, params: [] },
  326. { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
  327. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  328. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  329. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] }
  330. ],
  331. getDepartParam: {
  332. name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }
  333. },
  334. postDataPramas: {
  335. 'common': { 'returnmap': '0' },
  336. 'data': [
  337. { 'name': 'updateChangeStatue', 'type': 'e',
  338. 'parammaps': {
  339. 'status': '',
  340. 'assetId': '',
  341. 'pastureId': Cookies.get('pastureid')
  342. }},
  343. { 'name': 'updateAssetChange', 'type': 'e',
  344. 'parammaps': {
  345. 'changeStatue': '',
  346. 'assetId': '',
  347. 'assetName': '',
  348. 'assetNumber': '',
  349. 'pastureId': Cookies.get('pastureid'),
  350. 'empId': ''
  351. }}
  352. ] },
  353. temp: {
  354. pastureName: '',
  355. deptName: '',
  356. deptId: '',
  357. eqName: '',
  358. assetId: '',
  359. eqCode: '',
  360. status: '',
  361. statusId: '',
  362. inputDatetime: new Date(),
  363. typeName: '',
  364. assTypeId: '',
  365. syStatus: '',
  366. employeId: this.$store.state.user.employeid,
  367. departmentId: this.$store.state.user.departmentid,
  368. employeName: this.$store.state.user.employename,
  369. pastureId: this.$store.state.user.pastureid
  370. },
  371. dialogFormVisible: false,
  372. dialogStatus: '',
  373. textMap: {
  374. update: '修改状态',
  375. create: '新增'
  376. },
  377. dialogPvVisible: false,
  378. requestFilterParams: {
  379. name: 'findAssetMain', offset: 0, pagecount: 20,
  380. returntype: 'Map',
  381. parammaps: {}
  382. },
  383. // 新加的列表用的==========================================
  384. cardTitle: '变更记录',
  385. dialogFormVisibleCard: false,
  386. dialogStatusCard: '',
  387. listLoadingSee: true,
  388. rowSeeData: {},
  389. listSee: [],
  390. totalSee: 0,
  391. getdataListParmSee: {
  392. name: 'getAssetchangeList',
  393. page: 1,
  394. offset: 1,
  395. pagecount: 10,
  396. returntype: 'Map',
  397. parammaps: {
  398. eqId: '',
  399. changeStatue: '',
  400. inputDatetime: '',
  401. startTime: '',
  402. stopTime: '',
  403. pastureId: Cookies.get('pastureid')
  404. }
  405. },
  406. checkStatus: '',
  407. // 新加的列表用的==========================================
  408. // 时间设置
  409. pickerOptions0: {
  410. disabledDate(time) {
  411. return time.getTime() > Date.now() - 8.64e6
  412. }
  413. },
  414. // 校验规则
  415. rules: {
  416. assetName: [{ required: true, message: '必填', trigger: 'remove-tag' }],
  417. eqCode: [{ required: true, message: '必填', trigger: 'expand-change' }],
  418. equipmentName: [{ required: true, message: '必填', trigger: 'blur' }]
  419. },
  420. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  421. cellStyle: { padding: 0 + 'px' },
  422. isPercentage: false,
  423. percentage: 1
  424. }
  425. },
  426. created() {
  427. this.get_select_list()
  428. this.getList()
  429. },
  430. methods: {
  431. // 模糊查询-名称
  432. formNumberSearch(queryString, cb) {
  433. this.requestFilterParams.parammaps['eqCode'] = queryString
  434. this.requestFilterParams.parammaps['assetName'] = ''
  435. this.requestFilterParams.parammaps['pastureId'] = this.$store.state.user.pastureid
  436. GetDataByName(this.requestFilterParams).then(response => {
  437. cb(response.data.list)
  438. })
  439. },
  440. formNameSearch(queryString, cb) {
  441. this.requestFilterParams.parammaps['eqCode'] = ''
  442. this.requestFilterParams.parammaps['assetName'] = queryString
  443. this.requestFilterParams.parammaps['pastureId'] = this.$store.state.user.pastureid
  444. GetDataByName(this.requestFilterParams).then(response => {
  445. cb(response.data.list)
  446. })
  447. },
  448. handleformNumberSelect(item) {
  449. this.temp.assetNumber = item.assetNumber
  450. this.temp.assetName = item.assetName
  451. this.temp.eqCode = item.eqCode
  452. this.temp.eqName = item.eqName
  453. this.temp.eqId = item.eqId
  454. this.temp.id = item.assetId
  455. this.temp.assetId = item.assetId
  456. this.temp.pastureId = item.pastureId
  457. this.temp.pastureName = item.pastureName
  458. this.temp.deptName = item.deptName
  459. this.temp.deptId = item.deptName
  460. this.temp.changeStatue = item.changeStatue
  461. this.temp.status = item.status
  462. // this.temp.statusId = item.statusId
  463. this.checkStatus = item.status
  464. this.temp.employeId = item.employeId
  465. this.temp.employeName = item.employeName
  466. this.temp.inputDatetime = new Date()
  467. // this.temp.inputDatetime = this.temp.inputDatetime
  468. if (item.sttId === undefined || item.sttId === null) {
  469. this.temp.sttId = 0
  470. } else {
  471. this.temp.sttId = item.sttId
  472. }
  473. },
  474. handleformNameSelect(item) {
  475. console.log(item)
  476. this.temp.assetNumber = item.assetNumber
  477. this.temp.assetName = item.assetName
  478. this.temp.eqCode = item.eqCode
  479. this.temp.eqName = item.eqName
  480. this.temp.eqId = item.eqId
  481. this.temp.id = item.assetId
  482. this.temp.assetId = item.assetId
  483. this.temp.pastureId = item.pastureId
  484. this.temp.pastureName = item.pastureName
  485. this.temp.deptName = item.deptName
  486. this.temp.deptId = item.deptName
  487. this.temp.changeStatue = item.changeStatue
  488. this.temp.status = item.status
  489. // this.temp.statusId = item.statusId
  490. this.checkStatus = item.status
  491. this.temp.employeId = item.employeId
  492. this.temp.employeName = item.employeName
  493. // this.temp.inputDatetime = parse(new Date(), '{y}-{m}-{d} {h}:{i}')
  494. // this.temp.inputDatetime = this.temp.inputDatetime
  495. console.log(item.inputDatetime)
  496. if (item.sttId === undefined || item.sttId === null) {
  497. this.temp.sttId = 0
  498. } else {
  499. this.temp.sttId = item.sttId
  500. }
  501. },
  502. // 1-1: table&搜索
  503. getList() {
  504. this.listLoading = true
  505. GetDataByName(this.getdataListParm).then(response => {
  506. console.log('表格:', response.data.list)
  507. this.list = response.data.list
  508. if (response.data.list !== null) {
  509. for (let i = 0; i < response.data.list.length; i++) {
  510. if (response.data.list[i].srcpath !== null && response.data.list[i].picpath !== null && response.data.list[i].srcpath !== undefined && response.data.list[i].picpath !== undefined) {
  511. this.list[i].srcpath = process.env.VUE_APP_BASE_API + response.data.list[i].srcpath
  512. this.list[i].picpath = process.env.VUE_APP_BASE_API + response.data.list[i].picpath
  513. } else {
  514. this.list[i].srcpath = ''
  515. this.list[i].picpath = ''
  516. }
  517. console.log(this.list[i].srcpath)
  518. }
  519. }
  520. this.pageNum = response.data.pageNum
  521. this.pageSize = response.data.pageSize
  522. if (response.data.total) {
  523. this.total = response.data.total
  524. }
  525. // this.$refs['pastureName'].val = Cookies.get('employename')
  526. // console.log('-----------',this.$refs['pastureName'])
  527. // Just to simulate the time of the request
  528. setTimeout(() => {
  529. this.listLoading = false
  530. }, 100)
  531. })
  532. },
  533. // 2-2:下拉框
  534. get_select_list() {
  535. GetDataByNames(this.requestParams).then(response => {
  536. this.findAllProvider = response.data.findAllProvider.list
  537. this.findAllAssetType = response.data.findAllAssetType.list
  538. this.findAllPasture = response.data.findAllPasture.list
  539. this.findAllEmploye = response.data.findAllEmploye.list
  540. this.getDictByName = response.data.getDictByName.list
  541. this.getDepartDownList()
  542. })
  543. },
  544. getDepartDownList() {
  545. GetDataByName(this.getDepartParam).then(response => {
  546. this.findAllDepart = response.data.list
  547. })
  548. },
  549. changePastureName(item) {
  550. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  551. this.getdataListParm.parammaps.departmentId = ''
  552. this.getDepartDownList()
  553. },
  554. form_search() {
  555. this.listLoading = true
  556. this.getdataListParm.offset = 1
  557. this.getList()
  558. },
  559. handleModifyStatus(row, statusId) {
  560. this.$message({
  561. message: '操作成功',
  562. type: 'success'
  563. })
  564. // row.status = status
  565. row.statusId = statusId
  566. },
  567. form_reset() {
  568. this.temp = {
  569. pastureName: '',
  570. deptName: '',
  571. deptId: '',
  572. employeName: '',
  573. eqName: '',
  574. assetId: '',
  575. eqCode: '',
  576. status: '',
  577. statusId: '',
  578. inputDatetime: new Date(),
  579. typeName: '',
  580. assTypeId: '',
  581. syStatus: '',
  582. employeId: this.$store.state.user.employeid,
  583. departmentId: this.$store.state.user.departmentid,
  584. employeName: this.$store.state.user.employeid,
  585. pastureId: this.$store.state.user.pastureid
  586. }
  587. this.checkStatus = ''
  588. // this.temp.inputDatetime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')
  589. // this.temp.typeName = ''
  590. // this.temp.assTypeId = ''
  591. // this.temp.eqName = ''
  592. // this.temp.eqCode = ''
  593. // this.temp.deptName = ''
  594. // this.temp.deptId = ''
  595. // this.temp.status = ''
  596. // this.temp.statusId = ''
  597. // this.temp.pastureName = ''
  598. // this.temp.employeId = this.$store.state.user.employeId
  599. // this.temp.departmentId = this.$store.state.user.departmentid
  600. },
  601. add_dialog_save() {
  602. if (this.temp.assetId == '' || this.temp.eqCode == '' || this.temp.eqName == '') {
  603. this.$notify({
  604. title: '',
  605. message: '请输入设备名称或设备内部编号',
  606. type: 'warning',
  607. duration: 2000
  608. })
  609. } else {
  610. if (this.checkStatus == this.temp.status) {
  611. this.$notify({
  612. title: '',
  613. message: '请选择变更状态',
  614. type: 'warning',
  615. duration: 2000
  616. })
  617. } else {
  618. this.postDataPramas.data[0].parammaps.status = this.temp.status
  619. this.postDataPramas.data[0].parammaps.assetId = this.temp.assetId
  620. this.postDataPramas.data[1].parammaps.changeStatue = this.temp.status
  621. this.postDataPramas.data[1].parammaps.assetId = this.temp.assetId
  622. this.postDataPramas.data[1].parammaps.assetName = this.temp.eqName
  623. this.postDataPramas.data[1].parammaps.assetNumber = this.temp.eqCode
  624. this.postDataPramas.data[1].parammaps.empId = this.temp.empId
  625. ExecDataByConfig(this.postDataPramas).then(response => {
  626. if (response.msg === 'fail') {
  627. this.$notify({
  628. title: '变更失败',
  629. message: response.data,
  630. type: 'warning',
  631. duration: 2000
  632. })
  633. } else {
  634. this.getList()
  635. this.dialogFormVisible = false
  636. this.$notify({
  637. title: '',
  638. message: '变更成功',
  639. type: 'success',
  640. duration: 2000
  641. })
  642. }
  643. })
  644. }
  645. }
  646. },
  647. edit_dialog_save() {
  648. if (this.checkStatus == this.temp.status) {
  649. this.$notify({
  650. title: '',
  651. message: '请选择变更状态',
  652. type: 'warning',
  653. duration: 2000
  654. })
  655. } else {
  656. this.postDataPramas.data[0].parammaps.status = this.temp.status
  657. this.postDataPramas.data[0].parammaps.assetId = this.temp.assetId
  658. this.postDataPramas.data[1].parammaps.changeStatue = this.temp.status
  659. this.postDataPramas.data[1].parammaps.assetId = this.temp.assetId
  660. this.postDataPramas.data[1].parammaps.assetName = this.temp.eqName
  661. this.postDataPramas.data[1].parammaps.assetNumber = this.temp.eqCode
  662. this.postDataPramas.data[1].parammaps.empId = this.temp.empId
  663. this.postDataPramas.data[1].parammaps.changeId = this.temp.employeId
  664. ExecDataByConfig(this.postDataPramas).then(response => {
  665. if (response.msg === 'fail') {
  666. this.$notify({
  667. title: '变更失败',
  668. message: response.data,
  669. type: 'warning',
  670. duration: 2000
  671. })
  672. } else {
  673. this.getList()
  674. this.dialogFormVisible = false
  675. this.$notify({
  676. title: '',
  677. message: '变更成功',
  678. type: 'success',
  679. duration: 2000
  680. })
  681. }
  682. })
  683. }
  684. },
  685. form_edit(row) {
  686. console.log('row', row)
  687. this.temp = Object.assign({}, row) // copy obj
  688. this.temp.inputDatetime = new Date()
  689. this.temp.empId = this.$store.state.user.employeid
  690. this.checkStatus = row.status
  691. this.dialogStatus = 'update'
  692. this.dialogFormVisible = true
  693. this.$nextTick(() => {
  694. this.$refs['temp'].clearValidate()
  695. })
  696. },
  697. form_add() {
  698. this.form_reset()
  699. this.dialogStatus = 'create'
  700. this.dialogFormVisible = true
  701. this.temp.empId = this.$store.state.user.employeid
  702. this.$nextTick(() => {
  703. this.$refs['temp'].clearValidate()
  704. })
  705. },
  706. form_see(row) {
  707. console.log(row)
  708. this.rowSeeData = Object.assign({}, row)
  709. this.cardTitle = '变更记录 设备名称:' + row.eqName + '设备编号:' + row.eqCode
  710. this.dialogFormVisibleCard = true
  711. this.getdataListParmSee.parammaps.eqId = row.id
  712. this.getListSee()
  713. },
  714. form_searchDelivery() {
  715. // this.getdataListParmSee.parammaps.eqId = row.id
  716. if (this.getdataListParmSee.parammaps.inputDatetime === null) {
  717. this.getdataListParmSee.parammaps.inputDatetime = ''
  718. }
  719. console.log('getdataListParmSee', this.getdataListParmSee)
  720. this.getdataListParmSee.offset = 1
  721. this.getListSee()
  722. },
  723. getListSee() {
  724. console.log('enabledTime', this.$refs['inputDatetime2'])
  725. if (this.$refs['inputDatetime2'] !== undefined && this.$refs['inputDatetime2'].value !== null) {
  726. this.getdataListParmSee.parammaps.startTime = this.$refs['inputDatetime2'].value[0]
  727. this.getdataListParmSee.parammaps.stopTime = this.$refs['inputDatetime2'].value[1]
  728. } else {
  729. this.getdataListParmSee.parammaps.startTime = ''
  730. this.getdataListParmSee.parammaps.stopTime = ''
  731. }
  732. GetDataByName(this.getdataListParmSee).then(response => {
  733. this.listSee = response.data.list
  734. console.log('记录列表数据', response.data.list)
  735. this.pageNum = response.data.pageNum
  736. this.pageSize = response.data.pageSize
  737. if (response.data.total) {
  738. this.totalSee = response.data.total
  739. }
  740. // Just to simulate the time of the request
  741. setTimeout(() => {
  742. this.listLoadingSee = false
  743. }, 300)
  744. })
  745. },
  746. handleDownload() {
  747. this.$alert('设备变更正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  748. this.isPercentage = true
  749. this.percentage = 1
  750. var timer = setInterval(() => {
  751. this.percentage += 5
  752. if (this.percentage > 95) {
  753. this.percentage = 99
  754. clearInterval(timer)
  755. }
  756. this.percentage = this.percentage
  757. }, 1000)
  758. this.downLoadParm.name = 'geteqChangeList'
  759. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  760. GetAccount(this.downLoadParm).then(response => {
  761. this.downLoadList = response.data.list
  762. if (response.data.list !== '') {
  763. this.percentage = 99
  764. setTimeout(() => {
  765. this.isPercentage = false
  766. }, 2000)
  767. }
  768. console.log(this.downLoadList)
  769. const elecExcelDatas = [
  770. {
  771. tHeader: ['牧场', '设备名称', '设备内部编号', '规格', '品牌', '部门', '状态', '变更日期'],
  772. filterVal: ['pastureName', 'eqName', 'eqCode', 'specification', 'brandName', 'deptName', 'status', 'changeTime'],
  773. tableDatas: this.downLoadList,
  774. sheetName: '设备变更'
  775. }
  776. ]
  777. json2excel(elecExcelDatas, '设备变更', true, 'xlsx')
  778. })
  779. }
  780. }
  781. }
  782. </script>