baoyang.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. <template>
  2. <div class="app-container">
  3. <div>
  4. <el-button class="font-small" style="margin:0 10px 10px 0" type="primary" icon="el-icon-edit" @click="form_add"> 新增 </el-button>
  5. <el-button v-waves class="filter-item" type="info" icon="el-icon-tickets" style="margin:0 10px 10px 0" @click="handleDownloadTemp">模板</el-button>
  6. <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
  7. <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
  8. </el-upload>
  9. </div>
  10. <el-table
  11. v-loading="listLoading"
  12. element-loading-text="给我一点时间"
  13. :data="list"
  14. border
  15. fit
  16. highlight-current-row
  17. style="width: 100%;"
  18. :row-style="rowStyle"
  19. :cell-style="cellStyle"
  20. class="elTable table-fixed"
  21. row-key="id"
  22. default-expand-all
  23. @sort-change="tableSort"
  24. :max-height="myHeight"
  25. >
  26. <el-table-column label="序号" align="center" type="index" width="50px" />
  27. <el-table-column label="名称" min-width="100px" header-align="center" align="center">
  28. <template slot-scope="scope">
  29. <span>{{ scope.row.upkeepName }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="保养类型" min-width="100px" header-align="center" align="center">
  33. <template slot-scope="scope">
  34. <span>{{ scope.row.upkeepType }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="保养级别" min-width="100px" header-align="center" align="center">
  38. <template slot-scope="scope">
  39. <span>{{ scope.row.upkeepLevel }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="周期(天)" min-width="100px" sortable prop="upkeepCycel" header-align="center" align="center">
  43. <template slot-scope="scope">
  44. <span>{{ scope.row.upkeepCycel }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="启用" min-width="100px" header-align="center" align="center">
  48. <template slot-scope="scope">
  49. <el-switch
  50. v-model="scope.row.enable"
  51. :active-value="0"
  52. :inactive-value="1"
  53. active-color="#13ce66"
  54. inactive-color="#ff4949"
  55. @change="handleEnableChange(scope.$index, scope.row)"
  56. />
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="操作" align="center" width="400" fixed="right">
  60. <template slot-scope="{row}">
  61. <el-button type="primary" size="mini" @click="handleMaintenanceContents(row)">保养内容</el-button>
  62. <el-button type="primary" size="mini" @click="handleSparePart(row)">备件</el-button>
  63. <el-button type="warning" size="mini" @click="handleCopy(row)">复制</el-button>
  64. <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  65. <el-button v-if="row.status!='已删'" size="mini" type="danger" @click="form_delete(row)">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- 弹出层新增or修改 -->
  70. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="50%">
  71. <div class="content-add">
  72. <el-form
  73. ref="createTemp"
  74. :rules="rules"
  75. :model="createTemp"
  76. label-position="right"
  77. label-width="100px"
  78. style="width: 90%; margin:0 auto;"
  79. >
  80. <el-row>
  81. <el-col :span="20">
  82. <el-form-item label="保养名称:" prop="upkeepName">
  83. <el-input ref="upkeepName" v-model="createTemp.upkeepName" type="text" />
  84. </el-form-item>
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="20">
  89. <el-form-item label="保养类型:" prop="upkeepType">
  90. <el-select v-model="createTemp.upkeepType" placeholder="保养类型" class="filter-item" style="width:100%" @change="changeType">
  91. <el-option
  92. v-for="item in upkeepTypes"
  93. :key="item.id"
  94. :label="item.label"
  95. :value="item.label"
  96. />
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. </el-row>
  101. <el-row>
  102. <el-col :span="20">
  103. <el-form-item label="保养级别:" prop="upkeepLevel">
  104. <el-select v-model="createTemp.upkeepLevel" placeholder="保养级别" class="filter-item" style="width:100%">
  105. <el-option
  106. v-for="item in upkeepgrades"
  107. :key="item.id"
  108. :label="item.label"
  109. :value="item.label"
  110. />
  111. </el-select>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <el-row v-if="isDisplay">
  116. <el-col :span="20">
  117. <el-form-item label="保养周期:" prop="upkeepCycel">
  118. <el-input ref="upkeepCycel" v-model="createTemp.upkeepCycel" type="text" />
  119. </el-form-item>
  120. </el-col>
  121. </el-row>
  122. <el-row>
  123. <el-col :span="20">
  124. <el-form-item label="启用:" prop="enable">
  125. <el-switch
  126. v-model="createTemp.enable"
  127. :active-value="0"
  128. :inactive-value="1"
  129. active-color="#13ce66"
  130. inactive-color="#ff4949"
  131. />
  132. </el-form-item>
  133. </el-col>
  134. </el-row>
  135. </el-form>
  136. </div>
  137. <div slot="footer" class="dialog-footer">
  138. <el-button v-if="dialogStatus==='create'" ref="createb" type="success" :disabled="isokDisable" @click="add_dialog_save_again()">保存并新增</el-button>
  139. <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  140. <el-button @click="dialogFormVisible = false;get_table_data()">取消并关闭</el-button>
  141. </div>
  142. </el-dialog>
  143. <!-- 保养内容 -->
  144. <el-dialog :title="textMap[dialogStatusMaintenanceContents]" :visible.sync="dialogFormVisibleMaintenanceContents" :close-on-click-modal="false">
  145. <div class="content-MaintenanceContents">
  146. <el-form ref="maintenanceTemp" :rules="rules" :model="maintenanceTemp" label-position="right" label-width="100px" style="width: 90%; margin:0 auto;">
  147. <el-row>
  148. <el-col :span="10">
  149. <el-form-item label="保养部位:" prop="partCode">
  150. <el-autocomplete
  151. v-model="maintenanceTemp.positionName"
  152. value-key="name"
  153. class="inline-input"
  154. :fetch-suggestions="maintenanceSearch"
  155. placeholder="请输入备件编号或备件名称或备件规格"
  156. style="width:550px"
  157. @select="handleSelectMaintenance"
  158. >
  159. <template slot-scope="{ item }">
  160. <span class="addr">{{ item.positionName }}</span>
  161. </template>
  162. </el-autocomplete>
  163. </el-form-item>
  164. </el-col>
  165. </el-row>
  166. </el-form>
  167. <el-table
  168. :key="tableKey"
  169. v-loading="listLoading"
  170. element-loading-text="给我一点时间"
  171. :data="listMaintenance"
  172. border
  173. fit
  174. highlight-current-row
  175. style="width: 100%;margin-bottom:30px"
  176. :row-style="rowStyle"
  177. :cell-style="cellStyle"
  178. class="elTable"
  179. >
  180. <!-- table表格 -->
  181. <el-table-column label="序号" align="center" type="index" width="50px" />
  182. <el-table-column label="部位" min-width="90px" prop="positionName" align="center">
  183. <template slot-scope="scope">
  184. <span>{{ scope.row.positionName }}</span>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="项目" valign="middle" min-width="80px" align="center">
  188. <template slot-scope="scope">
  189. <el-input ref="program" v-model="scope.row.program" />
  190. </template>
  191. </el-table-column>
  192. <el-table-column label="标准" valign="middle" prop="standard" align="center" min-width="100">
  193. <template slot-scope="scope">
  194. <el-input ref="active" v-model="scope.row.standard" />
  195. </template>
  196. </el-table-column>
  197. <el-table-column valign="middle" label="执行动作" min-width="90px" align="center">
  198. <template slot-scope="scope">
  199. <el-form :model="scope.row">
  200. <el-form-item prop="active">
  201. <el-select
  202. v-model="scope.row.active"
  203. placeholder="执行动作"
  204. class="filter-item"
  205. style="width:100%;margin-top:15px"
  206. @change="handleActive"
  207. >
  208. <el-option
  209. v-for="item in listActive"
  210. :key="item.id"
  211. :label="item.label"
  212. :value="item.value"
  213. />
  214. </el-select>
  215. </el-form-item>
  216. </el-form>
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
  220. <template slot-scope="{row}">
  221. <!-- <a class="primary" @click="maintenanceSave(row)">保存</a> -->
  222. <a class="del" @click="maintenanceDelete(row)">删除</a>
  223. </template>
  224. </el-table-column>
  225. </el-table>
  226. </div>
  227. <div slot="footer" class="dialog-footer" style="bottom:10px">
  228. <el-button type="primary" :disabled="isokDisable" @click="maintenanceSave()">保存并关闭</el-button>
  229. <el-button @click="dialogFormVisibleMaintenanceContents = false;get_table_data()">关闭</el-button>
  230. </div>
  231. </el-dialog>
  232. <!-- 备件 -->
  233. <el-dialog :title="textMap[dialogStatusSparePart]" :visible.sync="dialogFormVisibleSparePart" :close-on-click-modal="false">
  234. <div class="content-SparePart">
  235. <el-form
  236. ref="sparePartTemp"
  237. :rules="rules"
  238. :model="sparePartTemp"
  239. label-position="right"
  240. label-width="100px"
  241. style="width: 90%; margin:0 auto;"
  242. >
  243. <el-row>
  244. <el-col :span="10">
  245. <el-form-item label="备件:" prop="partCode">
  246. <el-autocomplete
  247. v-model="sparePartTemp.partCode"
  248. value-key="name"
  249. class="inline-input"
  250. :fetch-suggestions="sparePartSearch"
  251. placeholder="请输入备件编号或备件名称或备件规格"
  252. style="width:550px"
  253. @select="handleSelectSparePart"
  254. >
  255. <template slot-scope="{ item }">
  256. <b>编号:</b><div class="name" style="display: inline;">{{ item.partCode }}</div>&nbsp;
  257. | &nbsp;<b>名称:</b><span class="addr">{{ item.name }}</span>
  258. </template>
  259. </el-autocomplete>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. </el-form>
  264. <el-table
  265. :key="tableKey"
  266. v-loading="listLoading"
  267. element-loading-text="给我一点时间"
  268. :data="listSparePart"
  269. border
  270. fit
  271. highlight-current-row
  272. style="width: 100%;margin-bottom:30px"
  273. :row-style="rowStyle"
  274. :cell-style="cellStyle"
  275. class="elTable"
  276. >
  277. <!-- table表格 -->
  278. <el-table-column label="序号" align="center" type="index" width="50px" />
  279. <el-table-column label="备件编号" min-width="90px" prop="partCode" align="center">
  280. <template slot-scope="scope">
  281. <span>{{ scope.row.partCode }}</span>
  282. </template>
  283. </el-table-column>
  284. <el-table-column label="备件名称" min-width="80px" align="center">
  285. <template slot-scope="scope">
  286. <span>{{ scope.row.partName }}</span><br>
  287. </template>
  288. </el-table-column>
  289. <el-table-column label="备件规格" prop="specification" align="center" min-width="100">
  290. <template slot-scope="scope">
  291. <span>{{ scope.row.specification }}</span>
  292. </template>
  293. </el-table-column>
  294. <el-table-column valign="middle" label="数量" min-width="90px" align="center">
  295. <template slot-scope="scope">
  296. <el-form :model="scope.row" :rules="rules">
  297. <el-form-item prop="amount">
  298. <el-input
  299. ref="amount"
  300. v-model="scope.row.amount"
  301. style="margin-top:15px"
  302. />
  303. </el-form-item>
  304. </el-form>
  305. </template>
  306. </el-table-column>
  307. <el-table-column valign="middle" label="备注" min-width="90px" align="center">
  308. <template slot-scope="scope">
  309. <el-form :model="scope.row" :rules="rules">
  310. <el-form-item prop="note">
  311. <el-input
  312. ref="note"
  313. v-model="scope.row.note"
  314. style="margin-top:15px"
  315. />
  316. </el-form-item>
  317. </el-form>
  318. </template>
  319. </el-table-column>
  320. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
  321. <template slot-scope="{row}">
  322. <!-- <a class="primary" @click="partSave(row)">保存</a> -->
  323. <a class="del" @click="partDelete(row)">删除</a>
  324. </template>
  325. </el-table-column>
  326. </el-table>
  327. </div>
  328. <div slot="footer" class="dialog-footer" style="bottom:10px">
  329. <el-button type="primary" :disabled="isokDisable" @click="partSave()">保存并关闭</el-button>
  330. <el-button @click="dialogFormVisibleSparePart = false">关闭</el-button>
  331. </div>
  332. </el-dialog>
  333. <!-- 复制 -->
  334. <el-dialog :title="textMap[dialogStatusCopy]" :visible.sync="dialogFormVisibleCopy" :close-on-click-modal="false">
  335. <div class="content-copy">
  336. <el-form
  337. label-position="right"
  338. label-width="110px"
  339. style="width: 90%px; margin: 0 auto;"
  340. >
  341. <el-row>
  342. <el-col :span="24">
  343. <el-form-item label="设备类别:" prop="NewName">
  344. <tree-select
  345. :disabled="disabled"
  346. :height="300"
  347. :width="300"
  348. size="small"
  349. multiple
  350. :data="parentType"
  351. :default-props="defaultProps"
  352. collapse-tags
  353. :node-key="nodeKey"
  354. :checked-keys="defaultCheckedKeys"
  355. @popoverHide="popoverHide"
  356. />
  357. </el-form-item>
  358. </el-col>
  359. </el-row>
  360. </el-form>
  361. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
  362. <el-button type="primary" @click="dialogStatus==='create'?createCopyData():createCopyData()">确认</el-button>
  363. <el-button @click="dialogFormVisibleCopy = false">关闭</el-button>
  364. </div>
  365. </div>
  366. </el-dialog>
  367. </div>
  368. </template>
  369. <script>
  370. import waves from '@/directive/waves' // waves directive
  371. import enterToNext from '@/directive/enterToNext' // enterToNext directive
  372. import { PostDataByName, GetDataByNames, GetDataByName, transData, ExecDataByConfig, failproccess } from '@/api/common'
  373. import { MessageBox } from 'element-ui'
  374. import TreeSelect from '@/components/TreeSelect'
  375. import Cookies from 'js-cookie'
  376. import { getToken } from '@/utils/auth'
  377. import { parseTime, sortChange } from '@/utils/index.js'
  378. export default {
  379. name: 'Baoyang',
  380. components: { TreeSelect },
  381. directives: { waves, enterToNext },
  382. props: {
  383. assetTypeid: {
  384. type: Number,
  385. default: 0
  386. }
  387. },
  388. data() {
  389. return {
  390. parentType: [],
  391. getParmType: {
  392. name: 'geteqclasslist'
  393. // idname: 'id',
  394. // params: [-1]
  395. },
  396. defaultProps: {
  397. children: 'children',
  398. label: 'typeName'
  399. },
  400. nodeKey: 'id',
  401. defaultCheckedKeys: [],
  402. dataform: {
  403. id: '',
  404. name: '',
  405. selectType: [],
  406. sort: '',
  407. enable: ''
  408. },
  409. UpdateDataRelationParam: {
  410. name: '',
  411. dataname: '',
  412. datavalue: '',
  413. valuename: '',
  414. values: ''
  415. },
  416. getdataListParm: {
  417. name: 'getPartList',
  418. parammaps: {
  419. id: ''
  420. }
  421. },
  422. copyTemp: {},
  423. upkeepTypes: [],
  424. upkeepgrades: [],
  425. listActive: [],
  426. requestParams: [
  427. { name: 'getDictByName1', offset: 0, pagecount: 0, params: ['保养类型'] },
  428. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['保养级别'] },
  429. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['保养模板执行动作'] }
  430. ],
  431. isDisplay: false,
  432. textMap: {
  433. create: '新增',
  434. update: '编辑',
  435. copy: '复制',
  436. maintenanceContents: '保养内容',
  437. sparePart: '备件'
  438. },
  439. dialogFormVisibleCopy: false,
  440. dialogStatusCopy: '',
  441. disabled: false,
  442. getdataListParmUpkeep: {
  443. name: 'getBigUpkeepTemplate',
  444. parammaps: {
  445. id: ''
  446. }
  447. },
  448. list: [],
  449. total: 0,
  450. listLoading: true,
  451. dialogStatus: '',
  452. dialogFormVisible: false,
  453. createTemp: {
  454. upkeepName: '',
  455. upkeepType: '',
  456. upkeepLevel: '',
  457. upkeepCycel: '',
  458. enable: 0
  459. },
  460. tableKey: 0,
  461. isokDisable: false,
  462. postDataPramas: {},
  463. dialogStatusMaintenanceContents: '',
  464. dialogFormVisibleMaintenanceContents: false,
  465. dialogFormVisibleSparePart: false,
  466. dialogStatusSparePart: '',
  467. getdataListParmSee: {
  468. name: 'getPositionPartBypid',
  469. page: 1,
  470. offset: 1,
  471. pagecount: 10,
  472. returntype: 'Map',
  473. parammaps: {}
  474. },
  475. requestParam: {},
  476. requestMaintenance: {
  477. name: 'getPositionByName',
  478. page: 1,
  479. offset: 1,
  480. pagecount: 10,
  481. returntype: 'Map',
  482. parammaps: {
  483. }
  484. },
  485. getMaintenanceListParm: {
  486. name: 'getUpkeepTemplateListbyeq',
  487. parammaps: {
  488. id: ''
  489. }
  490. },
  491. maintenanceTemp: {},
  492. listMaintenance: [],
  493. postMaintenancePramas: {},
  494. requestSparePart: {
  495. name: 'getPartsListUpkeep',
  496. page: 1,
  497. offset: 1,
  498. pagecount: 10,
  499. returntype: 'Map',
  500. parammaps: {}
  501. },
  502. getSparePartListParm: {
  503. name: 'getUpkeepPartListbyeq',
  504. parammaps: {
  505. id: ''
  506. }
  507. },
  508. sparePartTemp: {},
  509. listSparePart: [],
  510. postSparePartPramas: {},
  511. rules: {
  512. upkeepName: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  513. upkeepType: [{ required: true, message: '必填', trigger: 'blur' }],
  514. upkeepLevel: [{ required: true, message: '必填', trigger: 'blur' }],
  515. upkeepCycel: [{ type: 'number', required: true, validator: (rule, value, callback) => {
  516. if (!value) {
  517. callback(new Error('不能为空'))
  518. }
  519. setTimeout(() => {
  520. const re = /^[0-9]*[1-9][0-9]*$/ // /^[0-9]*[1-9][0-9]*$/
  521. const rsCheck = re.test(value)
  522. if (!rsCheck) {
  523. callback(new Error('请输入正整数'))
  524. } else {
  525. callback()
  526. }
  527. }, 0)
  528. }, trigger: 'blur' }]
  529. },
  530. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  531. cellStyle: { padding: 0 + 'px' },
  532. myHeight:document.documentElement.clientHeight - 85- 200
  533. }
  534. },
  535. computed: {
  536. headers() {
  537. return {
  538. token: getToken()
  539. }
  540. },
  541. uploadData() {
  542. return {
  543. name: 'updateUpKeepT',
  544. importParams: '设备类别名称,保养模板名称,保养级别,保养周期,保养类型,部位,项目,标准,执行动作',
  545. sheetname: 'SheetJS'
  546. }
  547. },
  548. // 设置上传地址
  549. uploadExcelUrl() {
  550. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  551. }
  552. },
  553. watch: {
  554. assetTypeid(val) {
  555. console.log(val)
  556. if (this.assetTypeid != null) {
  557. this.getdataListParmUpkeep.parammaps.id = this.assetTypeid
  558. this.get_table_data()
  559. this.getTypeList()
  560. }
  561. }
  562. },
  563. created() {
  564. this.get_table_data()
  565. this.get_select_list()
  566. },
  567. // 设置变量
  568. methods: {
  569. tableSort(column) {
  570. sortChange(column, this.list)
  571. },
  572. get_select_list() {
  573. GetDataByNames(this.requestParams).then(response => {
  574. this.upkeepTypes = response.data.getDictByName1.list
  575. this.upkeepgrades = response.data.getDictByName2.list
  576. this.listActive = response.data.getDictByName.list
  577. })
  578. },
  579. get_table_data() {
  580. this.listLoading = true
  581. GetDataByName(this.getdataListParmUpkeep).then(response => {
  582. console.log('部位table数据', response.data.list)
  583. this.list = response.data.list
  584. if (response.data.total) {
  585. this.total = response.data.total
  586. }
  587. // Just to simulate the time of the request
  588. setTimeout(() => {
  589. this.listLoading = false
  590. }, 100)
  591. })
  592. },
  593. handleEnableChange(index, row) {
  594. this.requestParam.name = 'setBigUpkeepTemplate'
  595. this.requestParam.parammaps = {}
  596. this.requestParam.parammaps.id = row.id
  597. this.requestParam.parammaps.enable = row.enable
  598. PostDataByName(this.requestParam).then(() => {
  599. this.$notify({
  600. title: '成功',
  601. message: '修改成功',
  602. type: 'success',
  603. duration: 2000
  604. })
  605. })
  606. },
  607. resetCreateTemp() {
  608. this.createTemp.upkeepName = ''
  609. this.createTemp.upkeepType = ''
  610. this.createTemp.upkeepLevel = ''
  611. this.createTemp.enable = 0
  612. },
  613. form_add() {
  614. if (this.assetTypeid != '') {
  615. this.resetCreateTemp()
  616. this.dialogStatus = 'create'
  617. this.dialogFormVisible = true
  618. console.log(this.assetTypeid)
  619. }
  620. },
  621. handleActive(val) {
  622. console.log('执行动作', val)
  623. },
  624. changeType(item) {
  625. console.log(item)
  626. if (item == '间隔保养') {
  627. this.createTemp.upkeepCycel = ''
  628. this.isDisplay = true
  629. } else if (item == '周保养') {
  630. this.createTemp.upkeepCycel = 7
  631. this.isDisplay = false
  632. } else if (item == '月保养') {
  633. this.createTemp.upkeepCycel = 30
  634. this.isDisplay = false
  635. }
  636. },
  637. add_dialog_save() {
  638. this.isokDisable = true
  639. setTimeout(() => {
  640. this.isokDisable = false
  641. }, 1000)
  642. this.$refs['createTemp'].validate(valid => {
  643. if (valid) {
  644. this.postDataPramas.name = 'insertBigUpkeepTemplate'
  645. this.postDataPramas.parammaps = this.createTemp
  646. this.postDataPramas.parammaps.eqclassId = this.assetTypeid
  647. PostDataByName(this.postDataPramas).then(response => {
  648. console.log('新增保存发送参数', this.requestParam)
  649. if (response.msg !== 'fail') {
  650. this.get_table_data()
  651. this.dialogFormVisible = false
  652. this.$notify({
  653. title: '成功',
  654. message: '新增成功',
  655. type: 'success',
  656. duration: 2000
  657. })
  658. } else {
  659. failproccess(response, this.$notify)
  660. }
  661. })
  662. }
  663. })
  664. },
  665. add_dialog_save_again() {
  666. this.isokDisable = true
  667. setTimeout(() => {
  668. this.isokDisable = false
  669. }, 1000)
  670. this.$refs['createTemp'].validate(valid => {
  671. if (valid) {
  672. this.postDataPramas.name = 'insertBigUpkeepTemplate'
  673. this.postDataPramas.parammaps = this.createTemp
  674. this.postDataPramas.parammaps.eqclassId = this.assetTypeid
  675. PostDataByName(this.postDataPramas).then(response => {
  676. console.log('新增保存发送参数', this.requestParam)
  677. if (response.msg !== 'fail') {
  678. this.resetCreateTemp()
  679. this.$notify({
  680. title: '成功',
  681. message: '新增成功',
  682. type: 'success',
  683. duration: 2000
  684. })
  685. } else {
  686. failproccess(response, this.$notify)
  687. }
  688. })
  689. }
  690. })
  691. },
  692. handleCopy(row) {
  693. if (this.assetTypeid != '') {
  694. this.dialogFormVisibleCopy = true
  695. this.dialogStatusCopy = 'copy'
  696. this.defaultCheckedKeys = []
  697. this.copyTemp = Object.assign({}, row)
  698. }
  699. },
  700. createCopyData() {
  701. console.log(this.dataform.selectType)
  702. if (this.dataform.selectType.length === 0) {
  703. this.$message({
  704. message: '请选择设备',
  705. type: 'warning',
  706. duration: 2000
  707. })
  708. } else {
  709. var selectedType = []
  710. for (var i = 0; i < this.dataform.selectType.length; i++) {
  711. var checkedIdsObj = {}
  712. checkedIdsObj['newEqclassId'] = this.dataform.selectType[i]
  713. selectedType.push(checkedIdsObj)
  714. }
  715. console.log('处理选中值', selectedType)
  716. this.dialogStatusCopy = 'copy'
  717. this.dialogFormVisibleCopy = true
  718. this.postDataPramas.common = { 'returnmap': '0' }
  719. this.postDataPramas.data = []
  720. this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': selectedType }}
  721. this.postDataPramas.data[0].children = []
  722. this.postDataPramas.data[0].children[0] = { 'name': 'CopyUpKeep', 'type': 'e', 'parammaps': {
  723. newEqclassId: '@insertSpotList.newEqclassId',
  724. eqclassid: this.copyTemp.id
  725. }}
  726. ExecDataByConfig(this.postDataPramas).then(response => {
  727. console.log('复制保存发送参数', this.postDataPramas)
  728. if (response.msg !== 'fail') {
  729. this.dialogFormVisibleCopy = false
  730. this.$notify({
  731. title: '成功',
  732. message: '复制成功',
  733. type: 'success',
  734. duration: 2000
  735. })
  736. } else {
  737. failproccess(response, this.$notify)
  738. }
  739. })
  740. }
  741. },
  742. popoverHide(checkedIds, checkedData) {
  743. console.log('选中值', checkedIds, checkedData)
  744. this.dataform.selectType = checkedIds
  745. this.UpdateDataRelationParam.values = checkedIds
  746. // eslint-disable-next-line no-unreachable
  747. },
  748. getTypeList() {
  749. GetDataByName(this.getParmType).then(response => {
  750. if (response.data.list !== null) {
  751. this.parentType = transData(response.data.list, 'id', 'pid', 'children')
  752. }
  753. })
  754. },
  755. handleMaintenanceContents(row) {
  756. this.maintenanceTemp = Object.assign({}, row)
  757. this.maintenanceTemp.bigId = row.id
  758. console.log(row)
  759. this.dialogStatusMaintenanceContents = 'maintenanceContents'
  760. this.dialogFormVisibleMaintenanceContents = true
  761. this.getMaintenanceList()
  762. },
  763. getMaintenanceList() {
  764. this.getMaintenanceListParm.parammaps.id = this.maintenanceTemp.id
  765. GetDataByName(this.getMaintenanceListParm).then(response => {
  766. console.log('保养部位数据', response.data.list)
  767. this.listMaintenance = response.data.list
  768. // Just to simulate the time of the request
  769. setTimeout(() => {
  770. this.listLoading = false
  771. }, 100)
  772. })
  773. },
  774. maintenanceSearch(queryString, cb) {
  775. console.log('保养部位模糊查询输入值', queryString)
  776. this.requestMaintenance.parammaps['positionName'] = queryString
  777. this.requestMaintenance.parammaps.id = this.assetTypeid
  778. GetDataByName(this.requestMaintenance).then(response => {
  779. console.log('保养部位模糊查询搜索data', response.data.list)
  780. cb(response.data.list)
  781. })
  782. },
  783. handleSelectMaintenance(item) {
  784. console.log('保养部位模糊查询选中值', item)
  785. if (this.listMaintenance != null) {
  786. this.$set(item, 'positionId', item.id)
  787. this.$set(item, 'myid', new Date().getTime())
  788. this.listMaintenance.push(item)
  789. } else {
  790. this.listMaintenance = []
  791. this.$set(item, 'myid', new Date().getTime())
  792. this.$set(item, 'positionId', item.id)
  793. this.listMaintenance.push(item)
  794. }
  795. },
  796. maintenanceDelete(row) {
  797. console.log(row)
  798. console.log(this.listMaintenance)
  799. MessageBox.confirm('名称:' + row.positionName, '确认删除?', {
  800. confirmButtonText: '确认',
  801. cancelButtonText: '取消',
  802. type: 'warning'
  803. }).then(() => {
  804. for (var i = 0; i < this.listMaintenance.length; i++) {
  805. console.log(this.listMaintenance[i])
  806. if (this.listMaintenance[i].myid == row.myid) {
  807. var listMaintenanceIndex = this.listMaintenance.indexOf(this.listMaintenance[i])
  808. }
  809. if (listMaintenanceIndex > -1) {
  810. this.listMaintenance.splice(listMaintenanceIndex, 1)
  811. return
  812. }
  813. }
  814. })
  815. },
  816. maintenanceSave(row) {
  817. if (this.listMaintenance.length !== 0) {
  818. for (var i = 0; i < this.listMaintenance.length; i++) {
  819. if (this.listMaintenance[i].program !== '' && this.listMaintenance[i].standard !== '' && this.listMaintenance[i].active !== '' && this.listMaintenance[i].program !== null && this.listMaintenance[i].standard !== null && this.listMaintenance[i].active !== null && this.listMaintenance[i].program !== undefined && this.listMaintenance[i].standard !== undefined && this.listMaintenance[i].active !== undefined) {
  820. this.postDataPramas.common = { 'returnmap': '0' }
  821. this.postDataPramas.data = []
  822. this.postDataPramas.data[0] = { 'name': 'deleteUpkeepTemplateListbyeq', 'type': 'e', 'parammaps': {
  823. id: this.maintenanceTemp.id
  824. }}
  825. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listMaintenance }}
  826. this.postDataPramas.data[1].children = []
  827. this.postDataPramas.data[1].children[0] = { 'name': 'insertUpkeepTemplate', 'type': 'e', 'parammaps': {
  828. bigId: this.maintenanceTemp.id,
  829. positionId: '@insertSpotList.positionId',
  830. program: '@insertSpotList.program',
  831. standard: '@insertSpotList.standard',
  832. active: '@insertSpotList.active',
  833. eqclassId: this.assetTypeid
  834. }}
  835. } else {
  836. this.$message({
  837. message: '请完善保养内容',
  838. type: 'warning',
  839. duration: 2000
  840. })
  841. }
  842. }
  843. ExecDataByConfig(this.postDataPramas).then(response => {
  844. console.log('备件保存发送参数', this.postDataPramas)
  845. if (response.msg !== 'fail') {
  846. this.dialogFormVisibleMaintenanceContents = false
  847. this.get_table_data()
  848. this.$notify({
  849. title: '成功',
  850. message: '保养成功',
  851. type: 'success',
  852. duration: 2000
  853. })
  854. } else {
  855. failproccess(response, this.$notify)
  856. }
  857. })
  858. }
  859. },
  860. handleSparePart(row) {
  861. this.sparePartTemp = Object.assign({}, row)
  862. this.dialogStatusSparePart = 'sparePart'
  863. this.dialogFormVisibleSparePart = true
  864. this.getSparePartList()
  865. },
  866. getSparePartList() {
  867. this.getSparePartListParm.parammaps.id = this.sparePartTemp.id
  868. GetDataByName(this.getSparePartListParm).then(response => {
  869. console.log('备件数据', response.data.list)
  870. this.listSparePart = response.data.list
  871. // Just to simulate the time of the request
  872. setTimeout(() => {
  873. this.listLoading = false
  874. }, 100)
  875. })
  876. },
  877. sparePartSearch(queryString, cb) {
  878. console.log('备件模糊查询输入值', queryString)
  879. this.requestSparePart.parammaps['partCode'] = queryString
  880. this.requestSparePart.parammaps.eqClassId = this.assetTypeid
  881. GetDataByName(this.requestSparePart).then(response => {
  882. console.log('备件模糊查询搜索data', response.data.list)
  883. cb(response.data.list)
  884. })
  885. },
  886. handleSelectSparePart(item) {
  887. console.log('备件模糊查询选中值', item)
  888. if (this.listSparePart != null) {
  889. // eslint-disable-next-line no-redeclare
  890. if (this.listSparePart.find(obj => obj.partId === item.id)) {
  891. this.$message({
  892. type: 'warning',
  893. message: '此备件已存在,请重新选择备件'
  894. })
  895. } else {
  896. this.$set(item, 'partId', item.id)
  897. this.$set(item, 'myid', new Date().getTime())
  898. this.listSparePart.push(item)
  899. }
  900. } else {
  901. this.listSparePart = []
  902. this.$set(item, 'partId', item.id)
  903. this.$set(item, 'myid', new Date().getTime())
  904. this.listSparePart.push(item)
  905. }
  906. this.sparePartTemp.partCode = ''
  907. },
  908. partDelete(row) {
  909. console.log(row)
  910. console.log(this.listSparePart)
  911. MessageBox.confirm('名称:' + row.positionName, '确认删除?', {
  912. confirmButtonText: '确认',
  913. cancelButtonText: '取消',
  914. type: 'warning'
  915. })
  916. .then(() => {
  917. for (var i = 0; i < this.listSparePart.length; i++) {
  918. console.log(this.listSparePart[i])
  919. if (this.listSparePart[i].myid == row.myid) {
  920. var listSparePartIndex = this.listSparePart.indexOf(this.listSparePart[i])
  921. }
  922. if (listSparePartIndex > -1) {
  923. this.listSparePart.splice(listSparePartIndex, 1)
  924. return
  925. }
  926. }
  927. })
  928. },
  929. partSave() {
  930. if (this.listSparePart.length !== 0) {
  931. for (var i = 0; i < this.listSparePart.length; i++) {
  932. if (this.listSparePart[i].amount !== '' && this.listSparePart[i].amount !== null && this.listSparePart[i].amount !== undefined) {
  933. this.postDataPramas.common = { 'returnmap': '0' }
  934. this.postDataPramas.data = []
  935. this.postDataPramas.data[0] = { 'name': 'deleteUpkeepPartbyeq', 'type': 'e', 'parammaps': {
  936. id: this.sparePartTemp.id
  937. }}
  938. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listSparePart }}
  939. this.postDataPramas.data[1].children = []
  940. this.postDataPramas.data[1].children[0] = { 'name': 'insertUpkeepPart', 'type': 'e', 'parammaps': {
  941. bigId: this.sparePartTemp.id,
  942. partId: '@insertSpotList.partId',
  943. partName: '@insertSpotList.partName',
  944. partCode: '@insertSpotList.partCode',
  945. specification: '@insertSpotList.specification',
  946. amount: '@insertSpotList.amount',
  947. note: '@insertSpotList.note'
  948. }}
  949. } else {
  950. this.$message({
  951. message: '请完善保养内容',
  952. type: 'warning',
  953. duration: 2000
  954. })
  955. }
  956. }
  957. ExecDataByConfig(this.postDataPramas).then(response => {
  958. console.log('备件保存发送参数', this.postDataPramas)
  959. if (response.msg !== 'fail') {
  960. this.dialogFormVisibleSparePart = false
  961. this.get_table_data()
  962. this.$notify({
  963. title: '成功',
  964. message: '保存成功',
  965. type: 'success',
  966. duration: 2000
  967. })
  968. } else {
  969. failproccess(response, this.$notify)
  970. }
  971. })
  972. }
  973. },
  974. // partSave(row) {
  975. // if (row.amount !== '' && row.amount !== null && row.amount !== undefined) {
  976. // this.postSparePartPramas.name = 'insertUpkeepPart'
  977. // this.postSparePartPramas.parammaps = row
  978. // this.postSparePartPramas.parammaps.eqclassId = this.assetTypeid
  979. // this.postSparePartPramas.parammaps.bigId = this.sparePartTemp.id
  980. // PostDataByName(this.postSparePartPramas).then(response => {
  981. // console.log('新增保存发送参数', this.postDataPramas)
  982. // if (response.msg === 'fail') {
  983. // this.$notify({
  984. // title: '保存失败',
  985. // message: response.data,
  986. // type: 'warning',
  987. // duration: 2000
  988. // })
  989. // } else {
  990. // this.getSparePartList()
  991. // this.$notify({
  992. // title: '',
  993. // message: '保存成功',
  994. // type: 'success',
  995. // duration: 2000
  996. // })
  997. // }
  998. // })
  999. // } else {
  1000. // this.$message({
  1001. // message: '请完善保养内容',
  1002. // type: 'warning',
  1003. // duration: 2000
  1004. // })
  1005. // }
  1006. // },
  1007. // partDelete(row) {
  1008. // console.log(row)
  1009. // console.log(this.listMaintenance)
  1010. // MessageBox.confirm('确认是否删除当前信息?', {
  1011. // confirmButtonText: '确认',
  1012. // cancelButtonText: '取消',
  1013. // type: 'warning'
  1014. // }).then(() => {
  1015. // this.postSparePartPramas.name = 'deleteUpkeepPart'
  1016. // this.postSparePartPramas.parammaps = {}
  1017. // this.postSparePartPramas.parammaps.id = row.id
  1018. // PostDataByName(this.postSparePartPramas).then(response => {
  1019. // console.log('新增保存发送参数', this.postDataPramas)
  1020. // if (response.msg === 'fail') {
  1021. // this.$notify({
  1022. // title: '保存失败',
  1023. // message: response.data,
  1024. // type: 'warning',
  1025. // duration: 2000
  1026. // })
  1027. // } else {
  1028. // this.getSparePartList()
  1029. // this.$notify({
  1030. // title: '',
  1031. // message: '保存成功',
  1032. // type: 'success',
  1033. // duration: 2000
  1034. // })
  1035. // }
  1036. // })
  1037. // })
  1038. // },
  1039. form_edit(row) {
  1040. this.dialogStatus = 'update'
  1041. this.dialogFormVisible = true
  1042. this.createTemp = Object.assign({}, row)
  1043. this.$nextTick(() => {
  1044. this.$refs['createTemp'].clearValidate()
  1045. })
  1046. },
  1047. edit_dialog_save() {
  1048. this.isokDisable = true
  1049. setTimeout(() => {
  1050. this.isokDisable = false
  1051. }, 1000)
  1052. this.$refs['createTemp'].validate(valid => {
  1053. if (valid) {
  1054. this.postDataPramas.name = 'updateBigUpkeepTemplate'
  1055. this.postDataPramas.parammaps = this.createTemp
  1056. PostDataByName(this.postDataPramas).then(response => {
  1057. console.log('编辑保存发送参数', this.requestParam)
  1058. if (response.msg !== 'fail') {
  1059. this.get_table_data()
  1060. this.dialogFormVisible = false
  1061. this.$notify({
  1062. title: '成功',
  1063. message: '编辑成功',
  1064. type: 'success',
  1065. duration: 2000
  1066. })
  1067. } else {
  1068. failproccess(response, this.$notify)
  1069. }
  1070. })
  1071. }
  1072. })
  1073. },
  1074. form_delete(row) {
  1075. MessageBox.confirm('确认删除?', {
  1076. confirmButtonText: '确认',
  1077. cancelButtonText: '取消',
  1078. type: 'warning'
  1079. })
  1080. .then(() => {
  1081. this.requestParam.name = 'deleteBigUpkeepTemplate'
  1082. this.requestParam.parammaps = {}
  1083. this.requestParam.parammaps.id = row.id
  1084. PostDataByName(this.requestParam).then((response) => {
  1085. if (response.msg !== 'fail') {
  1086. this.get_table_data()
  1087. this.$notify({
  1088. title: '成功',
  1089. message: '删除成功',
  1090. type: 'success',
  1091. duration: 2000
  1092. })
  1093. } else {
  1094. failproccess(response, this.$notify)
  1095. }
  1096. })
  1097. })
  1098. .catch(() => {
  1099. this.$message({
  1100. type: 'info',
  1101. message: '已取消删除'
  1102. })
  1103. })
  1104. },
  1105. beforeImportExcel(file) {
  1106. const isLt2M = file.size / 1024 / 1024 < 6
  1107. if (!isLt2M) {
  1108. this.$message.error('上传文件大小不能超过 6MB!')
  1109. }
  1110. return isLt2M
  1111. },
  1112. handleImportExcelSuccess(res, file) {
  1113. this.get_table_data()
  1114. if (res.msg === 'ok') {
  1115. this.$message({
  1116. title: '成功',
  1117. message: '导入成功:' + res.data.success + '条!',
  1118. type: 'success',
  1119. duration: 2000
  1120. })
  1121. if (res.data.err_count > 0) {
  1122. this.$notify({
  1123. title: '失败',
  1124. message: '导入失败:' + res.data.err_count + '条!',
  1125. type: 'danger',
  1126. duration: 2000
  1127. })
  1128. import('@/vendor/Export2Excel').then(excel => {
  1129. const list1 = res.data.result
  1130. const tHeader = [
  1131. '设备类别名称', '保养模板名称', '保养级别', '保养周期', '保养类型', '部位', '项目', '标准', '执行动作', '报错信息'
  1132. ]
  1133. const filterVal = [
  1134. '设备类别名称', '保养模板名称', '保养级别', '保养周期', '保养类型', '部位', '项目', '标准', '执行动作', 'error_msg'
  1135. ]
  1136. const data1 = this.formatJson(filterVal, list1)
  1137. excel.export_json_to_excel({
  1138. header: tHeader,
  1139. data: data1,
  1140. filename: '保养模板报错信息',
  1141. autoWidth: true,
  1142. bookType: 'xlsx'
  1143. })
  1144. })
  1145. }
  1146. } else {
  1147. this.$notify({
  1148. title: '失败',
  1149. message: '上传失败',
  1150. type: 'danger',
  1151. duration: 2000
  1152. })
  1153. }
  1154. },
  1155. formatJson(filterVal, jsonData) {
  1156. return jsonData.map(v =>
  1157. filterVal.map(j => {
  1158. if (j === 'timestamp') {
  1159. return parseTime(v[j])
  1160. } else {
  1161. return v[j]
  1162. }
  1163. })
  1164. )
  1165. },
  1166. // 导出模板
  1167. handleDownloadTemp() {
  1168. this.requestParam.name = 'pStockDownTemp'
  1169. GetDataByName(this.requestParam).then(response => {
  1170. this.$nextTick(() => {
  1171. import('@/vendor/Export2Excel').then(excel => {
  1172. const list1 = response.data.list
  1173. const tHeader = [
  1174. '设备类别名称', '保养模板名称', '保养级别', '保养周期', '保养类型', '部位', '项目', '标准', '执行动作'
  1175. ]
  1176. const filterVal = [
  1177. '设备类别名称', '保养模板名称', '保养级别', '保养周期', '保养类型', '部位', '项目', '标准', '执行动作'
  1178. ]
  1179. const data1 = this.formatJson(filterVal, list1)
  1180. excel.export_json_to_excel({
  1181. header: tHeader,
  1182. data: data1,
  1183. filename: '保养模板',
  1184. autoWidth: true,
  1185. bookType: 'xlsx'
  1186. })
  1187. })
  1188. })
  1189. })
  1190. },
  1191. // ------------------------------------------------------------------
  1192. jump() {
  1193. this.$router.push('/console/menu')
  1194. }
  1195. }
  1196. }
  1197. </script>