buwei1.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  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">
  5. 新增
  6. </el-button>
  7. <el-button class="font-small" type="warning" icon="el-icon-copy-document" @click="handleCopy">
  8. 复制
  9. </el-button>
  10. </div>
  11. <el-table
  12. v-loading="listLoading"
  13. element-loading-text="给我一点时间"
  14. :data="list"
  15. border
  16. fit
  17. highlight-current-row
  18. style="width: 100%;"
  19. :row-style="rowStyle"
  20. :cell-style="cellStyle"
  21. class="elTable table-fixed"
  22. row-key="id"
  23. default-expand-all
  24. >
  25. <el-table-column label="序号" align="center" type="index" width="50px" />
  26. <el-table-column label="部位" header-align="center" width="100px" align="center">
  27. <template slot-scope="scope">
  28. <span>{{ scope.row.positionName }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="备注" min-width="100px" header-align="center" align="center">
  32. <template slot-scope="scope">
  33. <span>{{ scope.row.note }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="操作" align="center" width="300" fixed="right">
  37. <template slot-scope="{row}">
  38. <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
  39. <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  40. <el-button type="success" size="mini" @click="handleSparePart(row)">备件</el-button>
  41. <el-button size="mini" type="danger" @click="form_delete(row)">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <!-- 弹出层新增or修改 -->
  46. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
  47. <div class="content-add">
  48. <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="100px" style="width: 90%; margin:0 auto;">
  49. <el-row>
  50. <el-col :span="8">
  51. <el-form-item label="部位名称:" prop="positionName">
  52. <el-input ref="positionName" v-model="createTemp.positionName" :disabled="dialogStatus==='sparePart'" type="text" />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="8">
  56. <el-form-item label="备注:" prop="note">
  57. <el-input ref="note" v-model="createTemp.note" class="note" :disabled="dialogStatus==='sparePart'" type="textarea" placeholder="备注" autosize maxlength="100" show-word-limit style="width:100%;" />
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. <el-row v-if="isUpdate">
  62. <el-col :span="20">
  63. <el-form-item label="备件:" prop="partCode">
  64. <el-autocomplete
  65. v-model="createTemp.partCode"
  66. value-key="name"
  67. class="inline-input"
  68. :fetch-suggestions="sparePartSearch"
  69. placeholder="请输入备件编号或备件名称或备件规格"
  70. style="width:100%"
  71. @select="handleSelectSparePart"
  72. >
  73. <template slot-scope="{ item }">
  74. <b>备件编号:</b><div class="name" style="display: inline;">{{ item.partCode }}</div>&nbsp;
  75. | &nbsp;<b>备件名称:</b><span class="addr">{{ item.partName }}</span>&nbsp;
  76. | &nbsp;<b>备件规格:</b><span class="addr">{{ item.specification }}</span>
  77. </template>
  78. </el-autocomplete>
  79. </el-form-item>
  80. </el-col>
  81. </el-row>
  82. </el-form>
  83. <el-table
  84. v-if="isUpdate"
  85. :key="tableKey"
  86. v-loading="listLoading"
  87. element-loading-text="给我一点时间"
  88. :data="listAdd"
  89. border
  90. fit
  91. highlight-current-row
  92. style="width: 100%;margin-bottom:30px"
  93. :row-style="rowStyle"
  94. :cell-style="cellStyle"
  95. class="elTable table-fixed"
  96. >
  97. <!-- table表格 -->
  98. <el-table-column label="序号" align="center" type="index" width="50px" />
  99. <el-table-column label="备件编号" min-width="90px" prop="partCode" align="center">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.partCode }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="备件名称" min-width="80px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.partName }}</span><br>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="备件规格" prop="specification" align="center" min-width="100">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.specification }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column valign="middle" label="配备数量" min-width="90px" align="center">
  115. <template slot-scope="scope">
  116. <el-form :model="scope.row" :rules="rules">
  117. <el-form-item prop="amount">
  118. <el-input
  119. ref="amount"
  120. v-model="scope.row.amount"
  121. style="margin-top:15px"
  122. />
  123. </el-form-item>
  124. </el-form>
  125. </template>
  126. </el-table-column>
  127. <el-table-column valign="middle" label="备注" min-width="90px" align="center">
  128. <template slot-scope="scope">
  129. <el-form :model="scope.row" :rules="rules">
  130. <el-form-item prop="note">
  131. <el-input
  132. ref="note"
  133. v-model="scope.row.note"
  134. style="margin-top:15px;"
  135. />
  136. </el-form-item>
  137. </el-form>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
  141. <template slot-scope="{row}">
  142. <!-- <a v-if="dialogStatus==='sparePart'" class="primary" @click="partSave(row)">保存</a> -->
  143. <!-- <a v-if="dialogStatus==='create'" class="del" @click="partDelete(row)">删除</a> -->
  144. <a class="del" @click="partUpdateDelete(row)">删除</a>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. </div>
  149. <div slot="footer" class="dialog-footer">
  150. <el-button v-if="dialogStatus==='create'" ref="createb" type="success" :disabled="isokDisable" @click="add_dialog_save_again()">保存并新增</el-button>
  151. <el-button v-if="dialogStatus==='create'" type="primary" :disabled="isokDisable" @click="add_dialog_save()">保存并关闭</el-button>
  152. <el-button v-if="dialogStatus==='create'" @click="dialogFormVisible = false;getList()">取消并关闭</el-button>
  153. <el-button v-if="dialogStatus==='sparePart'" type="primary" :disabled="isokDisable" @click="sparePartData()">保存并关闭</el-button>
  154. <el-button v-if="dialogStatus==='sparePart'" @click="dialogFormVisible = false;getList()">关闭</el-button>
  155. <el-button v-if="dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="edit_dialog_save()">保存并关闭</el-button>
  156. <el-button v-if="dialogStatus==='update'" @click="dialogFormVisible = false;getList()">关闭</el-button>
  157. </div>
  158. </el-dialog>
  159. <el-dialog
  160. :title="textMap[dialogStatusSee]"
  161. :visible.sync="dialogFormVisibleSee"
  162. :close-on-click-modal="false"
  163. >
  164. <div class="content-see">
  165. <el-form
  166. ref=" seeTemp"
  167. :rules="rules"
  168. :model=" seeTemp"
  169. label-position="right"
  170. label-width="120px"
  171. style="width: 90%;margin:0 auto;"
  172. >
  173. <el-row>
  174. <el-col :span="8">
  175. <el-form-item label="部位名称:" prop="positionName">
  176. <el-input ref="positionName" v-model="seeTemp.positionName" placeholder="请输入部位名称" disabled />
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="8">
  180. <el-form-item label="备注:" prop="note">
  181. <el-input ref="note" v-model="seeTemp.note" placeholder="请输入备注" disabled />
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. </el-form>
  186. <el-table
  187. v-loading="listLoadingSee"
  188. element-loading-text="给我一点时间"
  189. :data="listSee"
  190. border
  191. fit
  192. highlight-current-row
  193. style="width: 100%;"
  194. :row-style="rowStyle"
  195. :cell-style="cellStyle"
  196. class="elTable table-fixed"
  197. row-key="id"
  198. >
  199. <el-table-column label="序号" align="center" type="index" width="50px" />
  200. <el-table-column label="备件编号" header-align="center" width="100px" align="center">
  201. <template slot-scope="scope">
  202. <span>{{ scope.row.partCode }}</span>
  203. </template>
  204. </el-table-column>
  205. <el-table-column label="备件名称" min-width="100px" header-align="center" align="center">
  206. <template slot-scope="scope">
  207. <span>{{ scope.row.partName }}</span>
  208. </template>
  209. </el-table-column>
  210. <el-table-column label="备件规格" min-width="100px" header-align="center" align="center">
  211. <template slot-scope="scope">
  212. <span>{{ scope.row.specification }}</span>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="配备数量" min-width="100px" header-align="center" align="center">
  216. <template slot-scope="scope">
  217. <span>{{ scope.row.amount }}</span>
  218. </template>
  219. </el-table-column>
  220. <el-table-column label="备注" min-width="100px" header-align="center" align="center">
  221. <template slot-scope="scope">
  222. <span>{{ scope.row.note }}</span>
  223. </template>
  224. </el-table-column>
  225. </el-table>
  226. </div>
  227. <div slot="footer" class="dialog-footer" style="bottom:10px">
  228. <el-button @click="dialogFormVisibleSee = false">关闭</el-button>
  229. </div>
  230. </el-dialog>
  231. <!-- 弹出层复制信息 -->
  232. <el-dialog
  233. :title="textMap[dialogStatusCopy]"
  234. :visible.sync="dialogFormVisibleCopy"
  235. :close-on-click-modal="false"
  236. >
  237. <div class="content-copy">
  238. <el-form
  239. label-position="right"
  240. label-width="110px"
  241. style="width: 90%px; margin: 0 auto;"
  242. >
  243. <el-row>
  244. <el-col :span="24">
  245. <el-form-item label="设备类别:" prop="NewName">
  246. <tree-select
  247. :disabled="disabled"
  248. :width="300"
  249. size="small"
  250. multiple
  251. :data="parentType"
  252. :default-props="defaultProps"
  253. collapse-tags
  254. :node-key="nodeKey"
  255. :checked-keys="defaultCheckedKeys"
  256. @popoverHide="popoverHide"
  257. />
  258. </el-form-item>
  259. </el-col>
  260. </el-row>
  261. </el-form>
  262. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
  263. <el-button type="primary" @click="dialogStatus==='create'?createCopyData():createCopyData()">确认</el-button>
  264. <el-button @click="dialogFormVisibleCopy = false">关闭</el-button>
  265. </div>
  266. </div>
  267. </el-dialog>
  268. </div>
  269. </template>
  270. <script>
  271. import waves from '@/directive/waves' // waves directive
  272. import enterToNext from '@/directive/enterToNext' // enterToNext directive
  273. import { PostDataByName, GetDataByName, transData, ExecDataByConfig, failproccess } from '@/api/common'
  274. import { MessageBox } from 'element-ui'
  275. import TreeSelect from '@/components/TreeSelect'
  276. import Cookies from 'js-cookie'
  277. import { parseTime } from '@/utils/index.js'
  278. export default {
  279. name: 'Buwei',
  280. components: { TreeSelect },
  281. directives: { waves, enterToNext },
  282. props: {
  283. assetTypeid: {
  284. type: Number,
  285. default: 0
  286. }
  287. },
  288. data() {
  289. return {
  290. textMap: {
  291. create: '新增',
  292. update: '编辑',
  293. copy: '复制',
  294. see: '查看详情',
  295. sparePart: '备件'
  296. },
  297. dialogFormVisibleCopy: false,
  298. dialogStatusCopy: '',
  299. disabled: false,
  300. parentType: [],
  301. getParmType: {
  302. name: 'geteqclasslist'
  303. // idname: 'id',
  304. // params: [-1]
  305. },
  306. defaultProps: {
  307. children: 'children',
  308. label: 'typeName'
  309. },
  310. nodeKey: 'id',
  311. defaultCheckedKeys: [],
  312. dataform: {
  313. id: '',
  314. name: '',
  315. selectType: [],
  316. sort: '',
  317. enable: ''
  318. },
  319. UpdateDataRelationParam: {
  320. name: '',
  321. dataname: '',
  322. datavalue: '',
  323. valuename: '',
  324. values: ''
  325. },
  326. getdataListParm: {
  327. name: 'getPartList',
  328. parammaps: {
  329. id: ''
  330. }
  331. },
  332. list: [],
  333. total: 0,
  334. listLoading: true,
  335. dialogStatus: '',
  336. dialogFormVisible: false,
  337. createTemp: {
  338. part: '',
  339. note: ''
  340. },
  341. listAdd: [],
  342. tableKey: 0,
  343. isokDisable: false,
  344. requestSparePart: {
  345. name: 'getPartsListBW',
  346. page: 1,
  347. offset: 1,
  348. pagecount: 10,
  349. returntype: 'Map',
  350. parammaps: {
  351. pastureId: Cookies.get('pastureid')
  352. }
  353. },
  354. postDataPramas: {},
  355. seeTemp: {},
  356. dialogStatusSee: '',
  357. dialogFormVisibleSee: false,
  358. listLoadingSee: true,
  359. totalSee: 0,
  360. listSee: [],
  361. getdataListParmSee: {
  362. name: 'getPositionPartBypid',
  363. page: 1,
  364. offset: 1,
  365. pagecount: 10,
  366. returntype: 'Map',
  367. parammaps: {}
  368. },
  369. partTemp: {},
  370. postUpdatePramas: {},
  371. requestParam: {},
  372. rules: {
  373. positionName: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  374. },
  375. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  376. cellStyle: { padding: 0 + 'px' },
  377. isUpdate: false
  378. }
  379. },
  380. watch: {
  381. assetTypeid(val) {
  382. console.log(val)
  383. if (this.assetTypeid != null) {
  384. this.getdataListParm.parammaps.id = this.assetTypeid
  385. this.getList()
  386. this.getTypeList()
  387. }
  388. }
  389. },
  390. created() {
  391. this.getList()
  392. },
  393. // 设置变量
  394. methods: {
  395. // ------------------------------------------------------------------
  396. getList() {
  397. this.listLoading = true
  398. GetDataByName(this.getdataListParm).then(response => {
  399. console.log('部位table数据', response.data.list)
  400. this.list = response.data.list
  401. if (response.data.total) {
  402. this.total = response.data.total
  403. }
  404. // Just to simulate the time of the request
  405. setTimeout(() => {
  406. this.listLoading = false
  407. }, 100)
  408. })
  409. },
  410. resetCreateTemp() {
  411. this.listAdd = []
  412. this.createTemp = {}
  413. },
  414. form_add() {
  415. if (this.assetTypeid != '') {
  416. this.resetCreateTemp()
  417. this.dialogStatus = 'create'
  418. this.dialogFormVisible = true
  419. this.isUpdate = true
  420. console.log(this.assetTypeid)
  421. }
  422. },
  423. sparePartSearch(queryString, cb) {
  424. console.log('备件模糊查询输入值', queryString)
  425. this.requestSparePart.parammaps['partCode'] = queryString
  426. GetDataByName(this.requestSparePart).then(response => {
  427. console.log('备件模糊查询搜索data', response.data.list)
  428. cb(response.data.list)
  429. })
  430. },
  431. handleSelectSparePart(item) {
  432. console.log('备件模糊查询选中值', item)
  433. if (this.listAdd != null) {
  434. // eslint-disable-next-line no-redeclare
  435. if (this.listAdd.find(obj => obj.partId === item.partId)) {
  436. this.$message({
  437. type: 'warning',
  438. message: '此备件已存在,请重新选择备件'
  439. })
  440. } else {
  441. this.$set(item, 'myid', new Date().getTime())
  442. this.listAdd.unshift(item)
  443. }
  444. } else {
  445. this.listAdd = []
  446. this.$set(item, 'myid', new Date().getTime())
  447. this.listAdd.unshift(item)
  448. }
  449. console.log(this.listAdd, 'this.listAdd')
  450. },
  451. partDelete(row) {
  452. console.log(this.listAdd)
  453. MessageBox.confirm('设备名称:' + row.partName, '确认删除?', {
  454. confirmButtonText: '确认',
  455. cancelButtonText: '取消',
  456. type: 'warning'
  457. }).then(() => {
  458. // console.log(this.list2)
  459. for (var i = 0; i < this.listAdd.length; i++) {
  460. console.log(this.listAdd[i])
  461. if (this.listAdd[i].id === row.id) {
  462. var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
  463. }
  464. if (listAddIndex > -1) {
  465. this.listAdd.splice(listAddIndex, 1)
  466. return
  467. }
  468. }
  469. })
  470. },
  471. add_dialog_save() {
  472. this.isokDisable = true
  473. setTimeout(() => {
  474. this.isokDisable = false
  475. }, 1000)
  476. this.$refs['createTemp'].validate(valid => {
  477. if (valid) {
  478. console.log(this.listAdd)
  479. if (this.listAdd.length !== 0) {
  480. for (var i = 0; i < this.listAdd.length; i++) {
  481. if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
  482. this.$message({
  483. type: 'warning',
  484. message: '请检查配备数量是否未填写',
  485. duration: 2000
  486. })
  487. return false
  488. } else {
  489. var rulesValue = /^\d+(\.\d{1,3})?$/
  490. if (!rulesValue.test(parseFloat(this.listAdd[i].amount))) {
  491. this.$message({ type: 'error', message: '配备数量请输入自然数,最多保留两位小数点', duration: 2000 })
  492. return false
  493. } else {
  494. this.postDataPramas.common = { 'returnmap': '0' }
  495. this.postDataPramas.data = []
  496. this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
  497. positionName: this.createTemp.positionName,
  498. note: this.createTemp.note,
  499. id: this.assetTypeid
  500. }}
  501. // eslint-disable-next-line no-irregular-whitespace
  502. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
  503. this.postDataPramas.data[1].children = []
  504. this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
  505. positionId: '@insertPart.LastInsertId',
  506. note: '@insertSpotList.note',
  507. partId: '@insertSpotList.partId',
  508. amount: '@insertSpotList.amount'
  509. }}
  510. ExecDataByConfig(this.postDataPramas).then(response => {
  511. console.log('新增保存发送参数', this.postDataPramas)
  512. if (response.msg !== 'fail') {
  513. this.dialogFormVisible = false
  514. this.getList()
  515. this.$notify({
  516. title: '成功',
  517. message: '新增成功',
  518. type: 'success',
  519. duration: 2000
  520. })
  521. } else {
  522. failproccess(response, this.$notify)
  523. }
  524. })
  525. }
  526. return true
  527. }
  528. }
  529. } else {
  530. this.$notify({
  531. title: '',
  532. message: '请选择备件',
  533. type: 'warning',
  534. duration: 2000
  535. })
  536. return false
  537. }
  538. }
  539. })
  540. },
  541. add_dialog_save_again() {
  542. this.isokDisable = true
  543. setTimeout(() => {
  544. this.isokDisable = false
  545. }, 1000)
  546. this.$refs['createTemp'].validate(valid => {
  547. if (valid) {
  548. console.log(this.listAdd)
  549. if (this.listAdd.length !== 0) {
  550. for (var i = 0; i < this.listAdd.length; i++) {
  551. if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
  552. this.$message({
  553. type: 'warning',
  554. message: '请检查配备数量是否未填写',
  555. duration: 2000
  556. })
  557. return false
  558. } else {
  559. this.postDataPramas.common = { 'returnmap': '0' }
  560. this.postDataPramas.data = []
  561. this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
  562. positionName: this.createTemp.positionName,
  563. note: this.createTemp.note,
  564. id: this.assetTypeid
  565. }}
  566. // eslint-disable-next-line no-irregular-whitespace
  567. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
  568. this.postDataPramas.data[1].children = []
  569. this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
  570. positionId: '@insertPart.LastInsertId',
  571. note: '@insertSpotList.note',
  572. partId: '@insertSpotList.partId',
  573. amount: '@insertSpotList.amount'
  574. }}
  575. ExecDataByConfig(this.postDataPramas).then(response => {
  576. console.log('新增保存发送参数', this.postDataPramas)
  577. if (response.msg !== 'fail') {
  578. this.resetCreateTemp()
  579. this.$notify({
  580. title: '成功',
  581. message: '新增成功',
  582. type: 'success',
  583. duration: 2000
  584. })
  585. } else {
  586. failproccess(response, this.$notify)
  587. }
  588. })
  589. return true
  590. }
  591. }
  592. } else {
  593. this.$notify({
  594. title: '',
  595. message: '请选择备件',
  596. type: 'warning',
  597. duration: 2000
  598. })
  599. return false
  600. }
  601. }
  602. })
  603. },
  604. handleCopy() {
  605. if (this.assetTypeid != '') {
  606. this.dialogFormVisibleCopy = true
  607. this.dialogStatusCopy = 'copy'
  608. this.defaultCheckedKeys = []
  609. }
  610. },
  611. createCopyData() {
  612. console.log(this.dataform.selectType)
  613. if (this.dataform.selectType.length === 0) {
  614. this.$message({
  615. message: '请选择设备',
  616. type: 'warning',
  617. duration: 2000
  618. })
  619. } else {
  620. var selectedType = []
  621. for (var i = 0; i < this.dataform.selectType.length; i++) {
  622. var checkedIdsObj = {}
  623. checkedIdsObj['newEqclassId'] = this.dataform.selectType[i]
  624. selectedType.push(checkedIdsObj)
  625. }
  626. console.log('处理选中值', selectedType)
  627. this.dialogStatusCopy = 'copy'
  628. this.dialogFormVisibleCopy = true
  629. this.postDataPramas.common = { 'returnmap': '0' }
  630. this.postDataPramas.data = []
  631. this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': selectedType }}
  632. this.postDataPramas.data[0].children = []
  633. this.postDataPramas.data[0].children[0] = { 'name': 'CopyPosition', 'type': 'e', 'parammaps': {
  634. newEqclassId: '@insertSpotList.newEqclassId',
  635. eqclassid: this.assetTypeid
  636. }}
  637. ExecDataByConfig(this.postDataPramas).then(response => {
  638. console.log('复制保存发送参数', this.postDataPramas)
  639. if (response.msg !== 'fail') {
  640. this.dialogFormVisibleCopy = false
  641. this.$notify({
  642. title: '成功',
  643. message: '复制成功',
  644. type: 'success',
  645. duration: 2000
  646. })
  647. } else {
  648. failproccess(response, this.$notify)
  649. }
  650. })
  651. }
  652. },
  653. popoverHide(checkedIds, checkedData) {
  654. console.log('选中值', checkedIds, checkedData)
  655. this.dataform.selectType = checkedIds
  656. this.UpdateDataRelationParam.values = checkedIds
  657. // eslint-disable-next-line no-unreachable
  658. },
  659. getTypeList() {
  660. GetDataByName(this.getParmType).then(response => {
  661. if (response.data.list !== null) {
  662. this.parentType = transData(response.data.list, 'id', 'pid', 'children')
  663. }
  664. })
  665. },
  666. form_see(row) {
  667. console.log(row)
  668. this.seeTemp = Object.assign({}, row)
  669. this.dialogStatusSee = 'see'
  670. this.dialogFormVisibleSee = true
  671. this.getdataListParmSee.parammaps.positionId = row.id
  672. this.getListSee()
  673. },
  674. getListSee() {
  675. GetDataByName(this.getdataListParmSee).then(response => {
  676. console.log('部位table数据', response.data.list)
  677. this.listSee = response.data.list
  678. if (response.data.total) {
  679. this.totalSee = response.data.total
  680. }
  681. // Just to simulate the time of the request
  682. setTimeout(() => {
  683. this.listLoadingSee = false
  684. }, 100)
  685. })
  686. },
  687. form_edit(row) {
  688. this.dialogStatus = 'update'
  689. this.dialogFormVisible = true
  690. this.createTemp = Object.assign({}, row)
  691. this.isUpdate = false
  692. this.$nextTick(() => {
  693. this.$refs['createTemp'].clearValidate()
  694. })
  695. // this.getdataListParmSee.parammaps.positionId = row.id
  696. // this.getListPart()
  697. },
  698. edit_dialog_save() {
  699. this.postUpdatePramas.name = 'updatePosition'
  700. this.postUpdatePramas.parammaps = {}
  701. this.postUpdatePramas.parammaps.positionName = this.createTemp.positionName
  702. this.postUpdatePramas.parammaps.note = this.createTemp.note
  703. this.postUpdatePramas.parammaps.id = this.createTemp.id
  704. PostDataByName(this.postUpdatePramas).then(response => {
  705. console.log('编辑保存发送参数', this.postDataPramas)
  706. if (response.msg === 'fail') {
  707. this.$notify({
  708. title: '保存失败',
  709. message: response.data,
  710. type: 'warning',
  711. duration: 2000
  712. })
  713. } else {
  714. this.$notify({
  715. title: '',
  716. message: '保存成功',
  717. type: 'success',
  718. duration: 2000
  719. })
  720. this.dialogFormVisible = false
  721. this.getList()
  722. }
  723. })
  724. },
  725. handleSparePart(row) {
  726. this.dialogStatus = 'sparePart'
  727. this.dialogFormVisible = true
  728. this.createTemp = Object.assign({}, row)
  729. this.isUpdate = true
  730. this.$nextTick(() => {
  731. this.$refs['createTemp'].clearValidate()
  732. })
  733. this.getdataListParmSee.parammaps.positionId = row.id
  734. this.getListPart()
  735. },
  736. getListPart() {
  737. GetDataByName(this.getdataListParmSee).then(response => {
  738. console.log('部位table数据', response.data.list)
  739. this.listAdd = response.data.list
  740. // Just to simulate the time of the request
  741. setTimeout(() => {
  742. this.listLoading = false
  743. }, 100)
  744. })
  745. },
  746. // partSave(row) {
  747. // this.partTemp = Object.assign({}, row)
  748. // if (row.amount !== '' && row.amount !== null && row.amount !== undefined) {
  749. // this.postUpdatePramas.name = 'insertPositionPart'
  750. // // this.postUpdatePramas.parammaps = row
  751. // this.postUpdatePramas.parammaps = {}
  752. // this.postUpdatePramas.parammaps.positionId = this.createTemp.id
  753. // this.postUpdatePramas.parammaps.partId = this.partTemp.partId
  754. // this.postUpdatePramas.parammaps.note = this.partTemp.note
  755. // this.postUpdatePramas.parammaps.amount = this.partTemp.amount
  756. // PostDataByName(this.postUpdatePramas).then(response => {
  757. // console.log('新增保存发送参数', this.postDataPramas)
  758. // if (response.msg === 'fail') {
  759. // this.$notify({
  760. // title: '保存失败',
  761. // message: response.data,
  762. // type: 'warning',
  763. // duration: 2000
  764. // })
  765. // } else {
  766. // this.getListPart()
  767. // this.$notify({
  768. // title: '',
  769. // message: '保存成功',
  770. // type: 'success',
  771. // duration: 2000
  772. // })
  773. // }
  774. // })
  775. // } else {
  776. // this.$message({
  777. // message: '请完善保养内容',
  778. // type: 'warning',
  779. // duration: 2000
  780. // })
  781. // }
  782. // },
  783. // partUpdateDelete(row) {
  784. // console.log(row)
  785. // MessageBox.confirm('确认是否删除当前信息?', {
  786. // confirmButtonText: '确认',
  787. // cancelButtonText: '取消',
  788. // type: 'warning'
  789. // }).then(() => {
  790. // this.postUpdatePramas.name = 'deletePositionPart'
  791. // this.postUpdatePramas.parammaps = {}
  792. // this.postUpdatePramas.parammaps.id = row.id
  793. // PostDataByName(this.postUpdatePramas).then(response => {
  794. // console.log('新增保存发送参数', this.postDataPramas)
  795. // if (response.msg === 'fail') {
  796. // this.$notify({
  797. // title: '保存失败',
  798. // message: response.data,
  799. // type: 'warning',
  800. // duration: 2000
  801. // })
  802. // } else {
  803. // this.getListPart()
  804. // this.$notify({
  805. // title: '',
  806. // message: '保存成功',
  807. // type: 'success',
  808. // duration: 2000
  809. // })
  810. // }
  811. // })
  812. // })
  813. // },
  814. partUpdateDelete(row) {
  815. console.log(row)
  816. MessageBox.confirm('名称:' + row.partName, '确认删除?', {
  817. confirmButtonText: '确认',
  818. cancelButtonText: '取消',
  819. type: 'warning'
  820. })
  821. .then(() => {
  822. for (var i = 0; i < this.listAdd.length; i++) {
  823. console.log(this.listAdd[i])
  824. if (this.listAdd[i].myid == row.myid) {
  825. var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
  826. }
  827. if (listAddIndex > -1) {
  828. this.listAdd.splice(listAddIndex, 1)
  829. return
  830. }
  831. }
  832. })
  833. },
  834. sparePartData() {
  835. this.isokDisable = true
  836. setTimeout(() => {
  837. this.isokDisable = false
  838. }, 1000)
  839. console.log(this.listAdd)
  840. if (this.listAdd.length !== 0) {
  841. for (var i = 0; i < this.listAdd.length; i++) {
  842. if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
  843. this.$message({
  844. type: 'warning',
  845. message: '请检查配备数量是否未填写',
  846. duration: 2000
  847. })
  848. return false
  849. } else {
  850. var rulesValue = /^\d+(\.\d{1,3})?$/
  851. if (!rulesValue.test(parseFloat(this.listAdd[i].amount))) {
  852. this.$message({ type: 'error', message: '配备数量请输入自然数,最多保留两位小数点', duration: 2000 })
  853. return false
  854. } else {
  855. this.postDataPramas.common = { 'returnmap': '0' }
  856. this.postDataPramas.data = []
  857. this.postDataPramas.data[0] = { 'name': 'deletePositionpartByPid', 'type': 'e', 'parammaps': {
  858. positionId: this.createTemp.id
  859. }}
  860. // eslint-disable-next-line no-irregular-whitespace
  861. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
  862. this.postDataPramas.data[1].children = []
  863. this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
  864. positionId: this.createTemp.id,
  865. note: '@insertSpotList.note',
  866. partId: '@insertSpotList.partId',
  867. amount: '@insertSpotList.amount'
  868. }}
  869. ExecDataByConfig(this.postDataPramas).then(response => {
  870. console.log('备件保存发送参数', this.postDataPramas)
  871. if (response.msg !== 'fail') {
  872. this.dialogFormVisible = false
  873. this.getList()
  874. this.$notify({
  875. title: '成功',
  876. message: '新增成功',
  877. type: 'success',
  878. duration: 2000
  879. })
  880. } else {
  881. failproccess(response, this.$notify)
  882. }
  883. })
  884. }
  885. return true
  886. }
  887. }
  888. } else {
  889. this.$notify({
  890. title: '',
  891. message: '请选择备件',
  892. type: 'warning',
  893. duration: 2000
  894. })
  895. return false
  896. }
  897. },
  898. form_delete(row) {
  899. MessageBox.confirm('名称:' + row.positionName, '确认删除?', {
  900. confirmButtonText: '确认',
  901. cancelButtonText: '取消',
  902. type: 'warning'
  903. })
  904. .then(() => {
  905. this.requestParam.name = 'deletePart'
  906. this.requestParam.parammaps = {}
  907. this.requestParam.parammaps.id = row.id
  908. PostDataByName(this.requestParam).then(() => {
  909. this.getList()
  910. this.$notify({
  911. title: '成功',
  912. message: '删除成功',
  913. type: 'success',
  914. duration: 2000
  915. })
  916. })
  917. })
  918. .catch(() => {
  919. this.$message({
  920. type: 'info',
  921. message: '已取消删除'
  922. })
  923. })
  924. },
  925. // ------------------------------------------------------------------
  926. jump() {
  927. this.$router.push('/console/menu')
  928. }
  929. }
  930. }
  931. </script>
  932. <style lang="scss">
  933. .note textarea{
  934. height: 40px !important;
  935. line-height: 27px;
  936. }
  937. </style>