buwei.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  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. if(!this.createTemp.positionName)
  601. {
  602. this.$notify({
  603. title: '',
  604. message: '部位名称不能为空',
  605. type: 'warning',
  606. duration: 2000
  607. })
  608. return false
  609. }else{
  610. this.postDataPramas.common = { 'returnmap': '0' }
  611. this.postDataPramas.data = []
  612. this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
  613. positionName: this.createTemp.positionName,
  614. note: this.createTemp.note,
  615. id: this.assetTypeid
  616. }}
  617. ExecDataByConfig(this.postDataPramas).then(response => {
  618. console.log('新增保存发送参数', this.postDataPramas)
  619. if (response.msg !== 'fail') {
  620. this.dialogFormVisible = false
  621. this.getList()
  622. this.$notify({
  623. title: '成功',
  624. message: '新增成功',
  625. type: 'success',
  626. duration: 2000
  627. })
  628. } else {
  629. failproccess(response, this.$notify)
  630. }
  631. })
  632. return true
  633. }
  634. }
  635. }
  636. })
  637. },
  638. handleCopy() {
  639. if (this.assetTypeid != '') {
  640. this.dialogFormVisibleCopy = true
  641. this.dialogStatusCopy = 'copy'
  642. this.defaultCheckedKeys = []
  643. }
  644. },
  645. createCopyData() {
  646. console.log(this.dataform.selectType)
  647. if (this.dataform.selectType.length === 0) {
  648. this.$message({
  649. message: '请选择设备',
  650. type: 'warning',
  651. duration: 2000
  652. })
  653. } else {
  654. var selectedType = []
  655. for (var i = 0; i < this.dataform.selectType.length; i++) {
  656. var checkedIdsObj = {}
  657. checkedIdsObj['newEqclassId'] = this.dataform.selectType[i]
  658. selectedType.push(checkedIdsObj)
  659. }
  660. console.log('处理选中值', selectedType)
  661. this.dialogStatusCopy = 'copy'
  662. this.dialogFormVisibleCopy = true
  663. this.postDataPramas.common = { 'returnmap': '0' }
  664. this.postDataPramas.data = []
  665. this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': selectedType }}
  666. this.postDataPramas.data[0].children = []
  667. this.postDataPramas.data[0].children[0] = { 'name': 'CopyPosition', 'type': 'e', 'parammaps': {
  668. newEqclassId: '@insertSpotList.newEqclassId',
  669. eqclassid: this.assetTypeid
  670. }}
  671. ExecDataByConfig(this.postDataPramas).then(response => {
  672. console.log('复制保存发送参数', this.postDataPramas)
  673. if (response.msg !== 'fail') {
  674. this.dialogFormVisibleCopy = false
  675. this.$notify({
  676. title: '成功',
  677. message: '复制成功',
  678. type: 'success',
  679. duration: 2000
  680. })
  681. } else {
  682. failproccess(response, this.$notify)
  683. }
  684. })
  685. }
  686. },
  687. popoverHide(checkedIds, checkedData) {
  688. console.log('选中值', checkedIds, checkedData)
  689. this.dataform.selectType = checkedIds
  690. this.UpdateDataRelationParam.values = checkedIds
  691. // eslint-disable-next-line no-unreachable
  692. },
  693. getTypeList() {
  694. GetDataByName(this.getParmType).then(response => {
  695. if (response.data.list !== null) {
  696. this.parentType = transData(response.data.list, 'id', 'pid', 'children')
  697. }
  698. })
  699. },
  700. form_see(row) {
  701. console.log(row)
  702. this.seeTemp = Object.assign({}, row)
  703. this.dialogStatusSee = 'see'
  704. this.dialogFormVisibleSee = true
  705. this.getdataListParmSee.parammaps.positionId = row.id
  706. this.getListSee()
  707. },
  708. getListSee() {
  709. GetDataByName(this.getdataListParmSee).then(response => {
  710. console.log('部位table数据', response.data.list)
  711. this.listSee = response.data.list
  712. if (response.data.total) {
  713. this.totalSee = response.data.total
  714. }
  715. // Just to simulate the time of the request
  716. setTimeout(() => {
  717. this.listLoadingSee = false
  718. }, 100)
  719. })
  720. },
  721. form_edit(row) {
  722. this.dialogStatus = 'update'
  723. this.dialogFormVisible = true
  724. this.createTemp = Object.assign({}, row)
  725. this.isUpdate = false
  726. this.$nextTick(() => {
  727. this.$refs['createTemp'].clearValidate()
  728. })
  729. // this.getdataListParmSee.parammaps.positionId = row.id
  730. // this.getListPart()
  731. },
  732. edit_dialog_save() {
  733. this.postUpdatePramas.name = 'updatePosition'
  734. this.postUpdatePramas.parammaps = {}
  735. this.postUpdatePramas.parammaps.positionName = this.createTemp.positionName
  736. this.postUpdatePramas.parammaps.note = this.createTemp.note
  737. this.postUpdatePramas.parammaps.id = this.createTemp.id
  738. PostDataByName(this.postUpdatePramas).then(response => {
  739. console.log('编辑保存发送参数', this.postDataPramas)
  740. if (response.msg === 'fail') {
  741. this.$notify({
  742. title: '保存失败',
  743. message: response.data,
  744. type: 'warning',
  745. duration: 2000
  746. })
  747. } else {
  748. this.$notify({
  749. title: '',
  750. message: '保存成功',
  751. type: 'success',
  752. duration: 2000
  753. })
  754. this.dialogFormVisible = false
  755. this.getList()
  756. }
  757. })
  758. },
  759. handleSparePart(row) {
  760. this.dialogStatus = 'sparePart'
  761. this.dialogFormVisible = true
  762. this.createTemp = Object.assign({}, row)
  763. this.isUpdate = true
  764. this.$nextTick(() => {
  765. this.$refs['createTemp'].clearValidate()
  766. })
  767. this.getdataListParmSee.parammaps.positionId = row.id
  768. this.getListPart()
  769. },
  770. getListPart() {
  771. GetDataByName(this.getdataListParmSee).then(response => {
  772. console.log('部位table数据', response.data.list)
  773. this.listAdd = response.data.list
  774. // Just to simulate the time of the request
  775. setTimeout(() => {
  776. this.listLoading = false
  777. }, 100)
  778. })
  779. },
  780. // partSave(row) {
  781. // this.partTemp = Object.assign({}, row)
  782. // if (row.amount !== '' && row.amount !== null && row.amount !== undefined) {
  783. // this.postUpdatePramas.name = 'insertPositionPart'
  784. // // this.postUpdatePramas.parammaps = row
  785. // this.postUpdatePramas.parammaps = {}
  786. // this.postUpdatePramas.parammaps.positionId = this.createTemp.id
  787. // this.postUpdatePramas.parammaps.partId = this.partTemp.partId
  788. // this.postUpdatePramas.parammaps.note = this.partTemp.note
  789. // this.postUpdatePramas.parammaps.amount = this.partTemp.amount
  790. // PostDataByName(this.postUpdatePramas).then(response => {
  791. // console.log('新增保存发送参数', this.postDataPramas)
  792. // if (response.msg === 'fail') {
  793. // this.$notify({
  794. // title: '保存失败',
  795. // message: response.data,
  796. // type: 'warning',
  797. // duration: 2000
  798. // })
  799. // } else {
  800. // this.getListPart()
  801. // this.$notify({
  802. // title: '',
  803. // message: '保存成功',
  804. // type: 'success',
  805. // duration: 2000
  806. // })
  807. // }
  808. // })
  809. // } else {
  810. // this.$message({
  811. // message: '请完善保养内容',
  812. // type: 'warning',
  813. // duration: 2000
  814. // })
  815. // }
  816. // },
  817. // partUpdateDelete(row) {
  818. // console.log(row)
  819. // MessageBox.confirm('确认是否删除当前信息?', {
  820. // confirmButtonText: '确认',
  821. // cancelButtonText: '取消',
  822. // type: 'warning'
  823. // }).then(() => {
  824. // this.postUpdatePramas.name = 'deletePositionPart'
  825. // this.postUpdatePramas.parammaps = {}
  826. // this.postUpdatePramas.parammaps.id = row.id
  827. // PostDataByName(this.postUpdatePramas).then(response => {
  828. // console.log('新增保存发送参数', this.postDataPramas)
  829. // if (response.msg === 'fail') {
  830. // this.$notify({
  831. // title: '保存失败',
  832. // message: response.data,
  833. // type: 'warning',
  834. // duration: 2000
  835. // })
  836. // } else {
  837. // this.getListPart()
  838. // this.$notify({
  839. // title: '',
  840. // message: '保存成功',
  841. // type: 'success',
  842. // duration: 2000
  843. // })
  844. // }
  845. // })
  846. // })
  847. // },
  848. partUpdateDelete(row) {
  849. console.log(row)
  850. MessageBox.confirm('名称:' + row.partName, '确认删除?', {
  851. confirmButtonText: '确认',
  852. cancelButtonText: '取消',
  853. type: 'warning'
  854. })
  855. .then(() => {
  856. for (var i = 0; i < this.listAdd.length; i++) {
  857. console.log(this.listAdd[i])
  858. if (this.listAdd[i].myid == row.myid) {
  859. var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
  860. }
  861. if (listAddIndex > -1) {
  862. this.listAdd.splice(listAddIndex, 1)
  863. return
  864. }
  865. }
  866. })
  867. },
  868. sparePartData() {
  869. this.isokDisable = true
  870. setTimeout(() => {
  871. this.isokDisable = false
  872. }, 1000)
  873. console.log(this.listAdd)
  874. if (this.listAdd.length !== 0) {
  875. for (var i = 0; i < this.listAdd.length; i++) {
  876. if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
  877. this.$message({
  878. type: 'warning',
  879. message: '请检查配备数量是否未填写',
  880. duration: 2000
  881. })
  882. return false
  883. } else {
  884. var rulesValue = /^\d+(\.\d{1,3})?$/
  885. if (!rulesValue.test(parseFloat(this.listAdd[i].amount))) {
  886. this.$message({ type: 'error', message: '配备数量请输入自然数,最多保留两位小数点', duration: 2000 })
  887. return false
  888. } else {
  889. this.postDataPramas.common = { 'returnmap': '0' }
  890. this.postDataPramas.data = []
  891. this.postDataPramas.data[0] = { 'name': 'deletePositionpartByPid', 'type': 'e', 'parammaps': {
  892. positionId: this.createTemp.id
  893. }}
  894. // eslint-disable-next-line no-irregular-whitespace
  895. this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
  896. this.postDataPramas.data[1].children = []
  897. this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
  898. positionId: this.createTemp.id,
  899. note: '@insertSpotList.note',
  900. partId: '@insertSpotList.partId',
  901. amount: '@insertSpotList.amount'
  902. }}
  903. ExecDataByConfig(this.postDataPramas).then(response => {
  904. console.log('备件保存发送参数', this.postDataPramas)
  905. if (response.msg !== 'fail') {
  906. this.dialogFormVisible = false
  907. this.getList()
  908. this.$notify({
  909. title: '成功',
  910. message: '新增成功',
  911. type: 'success',
  912. duration: 2000
  913. })
  914. } else {
  915. failproccess(response, this.$notify)
  916. }
  917. })
  918. }
  919. return true
  920. }
  921. }
  922. } else {
  923. this.$notify({
  924. title: '',
  925. message: '请选择备件',
  926. type: 'warning',
  927. duration: 2000
  928. })
  929. return false
  930. }
  931. },
  932. form_delete(row) {
  933. MessageBox.confirm('名称:' + row.positionName, '确认删除?', {
  934. confirmButtonText: '确认',
  935. cancelButtonText: '取消',
  936. type: 'warning'
  937. })
  938. .then(() => {
  939. this.requestParam.name = 'deletePart'
  940. this.requestParam.parammaps = {}
  941. this.requestParam.parammaps.id = row.id
  942. PostDataByName(this.requestParam).then(() => {
  943. this.getList()
  944. this.$notify({
  945. title: '成功',
  946. message: '删除成功',
  947. type: 'success',
  948. duration: 2000
  949. })
  950. })
  951. })
  952. .catch(() => {
  953. this.$message({
  954. type: 'info',
  955. message: '已取消删除'
  956. })
  957. })
  958. },
  959. // ------------------------------------------------------------------
  960. jump() {
  961. this.$router.push('/console/menu')
  962. }
  963. }
  964. }
  965. </script>
  966. <style lang="scss">
  967. .note textarea{
  968. height: 40px !important;
  969. line-height: 27px;
  970. }
  971. </style>