123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981 |
- <template>
- <div class="app-container">
- <div>
- <el-button class="font-small" style="margin:0 10px 10px 0" type="primary" icon="el-icon-edit" @click="form_add">
- 新增
- </el-button>
- <el-button class="font-small" type="warning" icon="el-icon-copy-document" @click="handleCopy">
- 复制
- </el-button>
- </div>
- <el-table
- v-loading="listLoading"
- element-loading-text="给我一点时间"
- :data="list"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- row-key="id"
- default-expand-all
- >
- <el-table-column label="序号" align="center" type="index" width="50px" />
- <el-table-column label="部位" header-align="center" width="100px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.positionName }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.note }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="300" fixed="right">
- <template slot-scope="{row}">
- <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
- <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
- <el-button type="success" size="mini" @click="handleSparePart(row)">备件</el-button>
- <el-button size="mini" type="danger" @click="form_delete(row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 弹出层新增or修改 -->
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
- <div class="content-add">
- <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="100px" style="width: 90%; margin:0 auto;">
- <el-row>
- <el-col :span="8">
- <el-form-item label="部位名称:" prop="positionName">
- <el-input ref="positionName" v-model="createTemp.positionName" :disabled="dialogStatus==='sparePart'" type="text" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="备注:" prop="note">
- <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%;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-if="isUpdate">
- <el-col :span="20">
- <el-form-item label="备件:" prop="partCode">
- <el-autocomplete
- v-model="createTemp.partCode"
- value-key="name"
- class="inline-input"
- :fetch-suggestions="sparePartSearch"
- placeholder="请输入备件编号或备件名称或备件规格"
- style="width:100%"
- @select="handleSelectSparePart"
- >
- <template slot-scope="{ item }">
- <b>备件编号:</b><div class="name" style="display: inline;">{{ item.partCode }}</div>
- | <b>备件名称:</b><span class="addr">{{ item.partName }}</span>
- | <b>备件规格:</b><span class="addr">{{ item.specification }}</span>
- </template>
- </el-autocomplete>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <el-table
- v-if="isUpdate"
- :key="tableKey"
- v-loading="listLoading"
- element-loading-text="给我一点时间"
- :data="listAdd"
- border
- fit
- highlight-current-row
- style="width: 100%;margin-bottom:30px"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <!-- table表格 -->
- <el-table-column label="序号" align="center" type="index" width="50px" />
- <el-table-column label="备件编号" min-width="90px" prop="partCode" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.partCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备件名称" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.partName }}</span><br>
- </template>
- </el-table-column>
- <el-table-column label="备件规格" prop="specification" align="center" min-width="100">
- <template slot-scope="scope">
- <span>{{ scope.row.specification }}</span>
- </template>
- </el-table-column>
- <el-table-column valign="middle" label="配备数量" min-width="90px" align="center">
- <template slot-scope="scope">
- <el-form :model="scope.row" :rules="rules">
- <el-form-item prop="amount">
- <el-input
- ref="amount"
- v-model="scope.row.amount"
- style="margin-top:15px"
- />
- </el-form-item>
- </el-form>
- </template>
- </el-table-column>
- <el-table-column valign="middle" label="备注" min-width="90px" align="center">
- <template slot-scope="scope">
- <el-form :model="scope.row" :rules="rules">
- <el-form-item prop="note">
- <el-input
- ref="note"
- v-model="scope.row.note"
- style="margin-top:15px;"
- />
- </el-form-item>
- </el-form>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <!-- <a v-if="dialogStatus==='sparePart'" class="primary" @click="partSave(row)">保存</a> -->
- <!-- <a v-if="dialogStatus==='create'" class="del" @click="partDelete(row)">删除</a> -->
- <a class="del" @click="partUpdateDelete(row)">删除</a>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button v-if="dialogStatus==='create'" ref="createb" type="success" :disabled="isokDisable" @click="add_dialog_save_again()">保存并新增</el-button>
- <el-button v-if="dialogStatus==='create'" type="primary" :disabled="isokDisable" @click="add_dialog_save()">保存并关闭</el-button>
- <el-button v-if="dialogStatus==='create'" @click="dialogFormVisible = false;getList()">取消并关闭</el-button>
- <el-button v-if="dialogStatus==='sparePart'" type="primary" :disabled="isokDisable" @click="sparePartData()">保存并关闭</el-button>
- <el-button v-if="dialogStatus==='sparePart'" @click="dialogFormVisible = false;getList()">关闭</el-button>
- <el-button v-if="dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="edit_dialog_save()">保存并关闭</el-button>
- <el-button v-if="dialogStatus==='update'" @click="dialogFormVisible = false;getList()">关闭</el-button>
- </div>
- </el-dialog>
- <el-dialog
- :title="textMap[dialogStatusSee]"
- :visible.sync="dialogFormVisibleSee"
- :close-on-click-modal="false"
- >
- <div class="content-see">
- <el-form
- ref=" seeTemp"
- :rules="rules"
- :model=" seeTemp"
- label-position="right"
- label-width="120px"
- style="width: 90%;margin:0 auto;"
- >
- <el-row>
- <el-col :span="8">
- <el-form-item label="部位名称:" prop="positionName">
- <el-input ref="positionName" v-model="seeTemp.positionName" placeholder="请输入部位名称" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="备注:" prop="note">
- <el-input ref="note" v-model="seeTemp.note" placeholder="请输入备注" disabled />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <el-table
- v-loading="listLoadingSee"
- element-loading-text="给我一点时间"
- :data="listSee"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- row-key="id"
- >
- <el-table-column label="序号" align="center" type="index" width="50px" />
- <el-table-column label="备件编号" header-align="center" width="100px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.partCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备件名称" min-width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.partName }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备件规格" min-width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.specification }}</span>
- </template>
- </el-table-column>
- <el-table-column label="配备数量" min-width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.amount }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.note }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div slot="footer" class="dialog-footer" style="bottom:10px">
- <el-button @click="dialogFormVisibleSee = false">关闭</el-button>
- </div>
- </el-dialog>
- <!-- 弹出层复制信息 -->
- <el-dialog
- :title="textMap[dialogStatusCopy]"
- :visible.sync="dialogFormVisibleCopy"
- :close-on-click-modal="false"
- >
- <div class="content-copy">
- <el-form
- label-position="right"
- label-width="110px"
- style="width: 90%px; margin: 0 auto;"
- >
- <el-row>
- <el-col :span="24">
- <el-form-item label="设备类别:" prop="NewName">
- <tree-select
- :disabled="disabled"
- :width="300"
- size="small"
- multiple
- :data="parentType"
- :default-props="defaultProps"
- collapse-tags
- :node-key="nodeKey"
- :checked-keys="defaultCheckedKeys"
- @popoverHide="popoverHide"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
- <el-button type="primary" @click="dialogStatus==='create'?createCopyData():createCopyData()">确认</el-button>
- <el-button @click="dialogFormVisibleCopy = false">关闭</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import waves from '@/directive/waves' // waves directive
- import enterToNext from '@/directive/enterToNext' // enterToNext directive
- import { PostDataByName, GetDataByName, transData, ExecDataByConfig, failproccess } from '@/api/common'
- import { MessageBox } from 'element-ui'
- import TreeSelect from '@/components/TreeSelect'
- import Cookies from 'js-cookie'
- import { parseTime } from '@/utils/index.js'
- export default {
- name: 'Buwei',
- components: { TreeSelect },
- directives: { waves, enterToNext },
- props: {
- assetTypeid: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- textMap: {
- create: '新增',
- update: '编辑',
- copy: '复制',
- see: '查看详情',
- sparePart: '备件'
- },
- dialogFormVisibleCopy: false,
- dialogStatusCopy: '',
- disabled: false,
- parentType: [],
- getParmType: {
- name: 'geteqclasslist'
- // idname: 'id',
- // params: [-1]
- },
- defaultProps: {
- children: 'children',
- label: 'typeName'
- },
- nodeKey: 'id',
- defaultCheckedKeys: [],
- dataform: {
- id: '',
- name: '',
- selectType: [],
- sort: '',
- enable: ''
- },
- UpdateDataRelationParam: {
- name: '',
- dataname: '',
- datavalue: '',
- valuename: '',
- values: ''
- },
- getdataListParm: {
- name: 'getPartList',
- parammaps: {
- id: ''
- }
- },
- list: [],
- total: 0,
- listLoading: true,
- dialogStatus: '',
- dialogFormVisible: false,
- createTemp: {
- part: '',
- note: ''
- },
- listAdd: [],
- tableKey: 0,
- isokDisable: false,
- requestSparePart: {
- name: 'getPartsListBW',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureId: Cookies.get('pastureid')
- }
- },
- postDataPramas: {},
- seeTemp: {},
- dialogStatusSee: '',
- dialogFormVisibleSee: false,
- listLoadingSee: true,
- totalSee: 0,
- listSee: [],
- getdataListParmSee: {
- name: 'getPositionPartBypid',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {}
- },
- partTemp: {},
- postUpdatePramas: {},
- requestParam: {},
- rules: {
- positionName: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- },
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' },
- isUpdate: false
- }
- },
- watch: {
- assetTypeid(val) {
- console.log(val)
- if (this.assetTypeid != null) {
- this.getdataListParm.parammaps.id = this.assetTypeid
- this.getList()
- this.getTypeList()
- }
- }
- },
- created() {
- this.getList()
- },
- // 设置变量
- methods: {
- // ------------------------------------------------------------------
- getList() {
- this.listLoading = true
- GetDataByName(this.getdataListParm).then(response => {
- console.log('部位table数据', response.data.list)
- this.list = response.data.list
- if (response.data.total) {
- this.total = response.data.total
- }
- // Just to simulate the time of the request
- setTimeout(() => {
- this.listLoading = false
- }, 100)
- })
- },
- resetCreateTemp() {
- this.listAdd = []
- this.createTemp = {}
- },
- form_add() {
- if (this.assetTypeid != '') {
- this.resetCreateTemp()
- this.dialogStatus = 'create'
- this.dialogFormVisible = true
- this.isUpdate = true
- console.log(this.assetTypeid)
- }
- },
- sparePartSearch(queryString, cb) {
- console.log('备件模糊查询输入值', queryString)
- this.requestSparePart.parammaps['partCode'] = queryString
- GetDataByName(this.requestSparePart).then(response => {
- console.log('备件模糊查询搜索data', response.data.list)
- cb(response.data.list)
- })
- },
- handleSelectSparePart(item) {
- console.log('备件模糊查询选中值', item)
- if (this.listAdd != null) {
- // eslint-disable-next-line no-redeclare
- if (this.listAdd.find(obj => obj.partId === item.partId)) {
- this.$message({
- type: 'warning',
- message: '此备件已存在,请重新选择备件'
- })
- } else {
- this.$set(item, 'myid', new Date().getTime())
- this.listAdd.unshift(item)
- }
- } else {
- this.listAdd = []
- this.$set(item, 'myid', new Date().getTime())
- this.listAdd.unshift(item)
- }
- console.log(this.listAdd, 'this.listAdd')
- },
- partDelete(row) {
- console.log(this.listAdd)
- MessageBox.confirm('设备名称:' + row.partName, '确认删除?', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- // console.log(this.list2)
- for (var i = 0; i < this.listAdd.length; i++) {
- console.log(this.listAdd[i])
- if (this.listAdd[i].id === row.id) {
- var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
- }
- if (listAddIndex > -1) {
- this.listAdd.splice(listAddIndex, 1)
- return
- }
- }
- })
- },
- add_dialog_save() {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- console.log(this.listAdd)
- if (this.listAdd.length !== 0) {
- for (var i = 0; i < this.listAdd.length; i++) {
- if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
- this.$message({
- type: 'warning',
- message: '请检查配备数量是否未填写',
- duration: 2000
- })
- return false
- } else {
- var rulesValue = /^\d+(\.\d{1,3})?$/
- if (!rulesValue.test(parseFloat(this.listAdd[i].amount))) {
- this.$message({ type: 'error', message: '配备数量请输入自然数,最多保留两位小数点', duration: 2000 })
- return false
- } else {
- this.postDataPramas.common = { 'returnmap': '0' }
- this.postDataPramas.data = []
- this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
- positionName: this.createTemp.positionName,
- note: this.createTemp.note,
- id: this.assetTypeid
- }}
- // eslint-disable-next-line no-irregular-whitespace
- this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
- this.postDataPramas.data[1].children = []
- this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
- positionId: '@insertPart.LastInsertId',
- note: '@insertSpotList.note',
- partId: '@insertSpotList.partId',
- amount: '@insertSpotList.amount'
- }}
- ExecDataByConfig(this.postDataPramas).then(response => {
- console.log('新增保存发送参数', this.postDataPramas)
- if (response.msg !== 'fail') {
- this.dialogFormVisible = false
- this.getList()
- this.$notify({
- title: '成功',
- message: '新增成功',
- type: 'success',
- duration: 2000
- })
- } else {
- failproccess(response, this.$notify)
- }
- })
- }
- return true
- }
- }
- } else {
- this.$notify({
- title: '',
- message: '请选择备件',
- type: 'warning',
- duration: 2000
- })
- return false
- }
- }
- })
- },
- add_dialog_save_again() {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- console.log(this.listAdd)
- if (this.listAdd.length !== 0) {
- for (var i = 0; i < this.listAdd.length; i++) {
- if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
- this.$message({
- type: 'warning',
- message: '请检查配备数量是否未填写',
- duration: 2000
- })
- return false
- } else {
- this.postDataPramas.common = { 'returnmap': '0' }
- this.postDataPramas.data = []
- this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
- positionName: this.createTemp.positionName,
- note: this.createTemp.note,
- id: this.assetTypeid
- }}
- // eslint-disable-next-line no-irregular-whitespace
- this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
- this.postDataPramas.data[1].children = []
- this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
- positionId: '@insertPart.LastInsertId',
- note: '@insertSpotList.note',
- partId: '@insertSpotList.partId',
- amount: '@insertSpotList.amount'
- }}
- ExecDataByConfig(this.postDataPramas).then(response => {
- console.log('新增保存发送参数', this.postDataPramas)
- if (response.msg !== 'fail') {
- this.resetCreateTemp()
- this.$notify({
- title: '成功',
- message: '新增成功',
- type: 'success',
- duration: 2000
- })
- } else {
- failproccess(response, this.$notify)
- }
- })
- return true
- }
- }
- } else {
- // this.$notify({
- // title: '',
- // message: '请选择备件',
- // type: 'warning',
- // duration: 2000
- // })
- // return false
- if(!this.createTemp.positionName)
- {
- this.$notify({
- title: '',
- message: '部位名称不能为空',
- type: 'warning',
- duration: 2000
- })
- return false
- }else{
- this.postDataPramas.common = { 'returnmap': '0' }
- this.postDataPramas.data = []
- this.postDataPramas.data[0] = { 'name': 'insertPart', 'type': 'e', 'parammaps': {
- positionName: this.createTemp.positionName,
- note: this.createTemp.note,
- id: this.assetTypeid
- }}
- ExecDataByConfig(this.postDataPramas).then(response => {
- console.log('新增保存发送参数', this.postDataPramas)
- if (response.msg !== 'fail') {
- this.dialogFormVisible = false
- this.getList()
- this.$notify({
- title: '成功',
- message: '新增成功',
- type: 'success',
- duration: 2000
- })
- } else {
- failproccess(response, this.$notify)
- }
- })
- return true
- }
- }
- }
- })
- },
- handleCopy() {
- if (this.assetTypeid != '') {
- this.dialogFormVisibleCopy = true
- this.dialogStatusCopy = 'copy'
- this.defaultCheckedKeys = []
- }
- },
- createCopyData() {
- console.log(this.dataform.selectType)
- if (this.dataform.selectType.length === 0) {
- this.$message({
- message: '请选择设备',
- type: 'warning',
- duration: 2000
- })
- } else {
- var selectedType = []
- for (var i = 0; i < this.dataform.selectType.length; i++) {
- var checkedIdsObj = {}
- checkedIdsObj['newEqclassId'] = this.dataform.selectType[i]
- selectedType.push(checkedIdsObj)
- }
- console.log('处理选中值', selectedType)
- this.dialogStatusCopy = 'copy'
- this.dialogFormVisibleCopy = true
- this.postDataPramas.common = { 'returnmap': '0' }
- this.postDataPramas.data = []
- this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': selectedType }}
- this.postDataPramas.data[0].children = []
- this.postDataPramas.data[0].children[0] = { 'name': 'CopyPosition', 'type': 'e', 'parammaps': {
- newEqclassId: '@insertSpotList.newEqclassId',
- eqclassid: this.assetTypeid
- }}
- ExecDataByConfig(this.postDataPramas).then(response => {
- console.log('复制保存发送参数', this.postDataPramas)
- if (response.msg !== 'fail') {
- this.dialogFormVisibleCopy = false
- this.$notify({
- title: '成功',
- message: '复制成功',
- type: 'success',
- duration: 2000
- })
- } else {
- failproccess(response, this.$notify)
- }
- })
- }
- },
- popoverHide(checkedIds, checkedData) {
- console.log('选中值', checkedIds, checkedData)
- this.dataform.selectType = checkedIds
- this.UpdateDataRelationParam.values = checkedIds
- // eslint-disable-next-line no-unreachable
- },
- getTypeList() {
- GetDataByName(this.getParmType).then(response => {
- if (response.data.list !== null) {
- this.parentType = transData(response.data.list, 'id', 'pid', 'children')
- }
- })
- },
- form_see(row) {
- console.log(row)
- this.seeTemp = Object.assign({}, row)
- this.dialogStatusSee = 'see'
- this.dialogFormVisibleSee = true
- this.getdataListParmSee.parammaps.positionId = row.id
- this.getListSee()
- },
- getListSee() {
- GetDataByName(this.getdataListParmSee).then(response => {
- console.log('部位table数据', response.data.list)
- this.listSee = response.data.list
- if (response.data.total) {
- this.totalSee = response.data.total
- }
- // Just to simulate the time of the request
- setTimeout(() => {
- this.listLoadingSee = false
- }, 100)
- })
- },
- form_edit(row) {
- this.dialogStatus = 'update'
- this.dialogFormVisible = true
- this.createTemp = Object.assign({}, row)
- this.isUpdate = false
- this.$nextTick(() => {
- this.$refs['createTemp'].clearValidate()
- })
- // this.getdataListParmSee.parammaps.positionId = row.id
- // this.getListPart()
- },
- edit_dialog_save() {
- this.postUpdatePramas.name = 'updatePosition'
- this.postUpdatePramas.parammaps = {}
- this.postUpdatePramas.parammaps.positionName = this.createTemp.positionName
- this.postUpdatePramas.parammaps.note = this.createTemp.note
- this.postUpdatePramas.parammaps.id = this.createTemp.id
- PostDataByName(this.postUpdatePramas).then(response => {
- console.log('编辑保存发送参数', this.postDataPramas)
- if (response.msg === 'fail') {
- this.$notify({
- title: '保存失败',
- message: response.data,
- type: 'warning',
- duration: 2000
- })
- } else {
- this.$notify({
- title: '',
- message: '保存成功',
- type: 'success',
- duration: 2000
- })
- this.dialogFormVisible = false
- this.getList()
- }
- })
- },
- handleSparePart(row) {
- this.dialogStatus = 'sparePart'
- this.dialogFormVisible = true
- this.createTemp = Object.assign({}, row)
- this.isUpdate = true
- this.$nextTick(() => {
- this.$refs['createTemp'].clearValidate()
- })
- this.getdataListParmSee.parammaps.positionId = row.id
- this.getListPart()
- },
- getListPart() {
- GetDataByName(this.getdataListParmSee).then(response => {
- console.log('部位table数据', response.data.list)
- this.listAdd = response.data.list
- // Just to simulate the time of the request
- setTimeout(() => {
- this.listLoading = false
- }, 100)
- })
- },
- // partSave(row) {
- // this.partTemp = Object.assign({}, row)
- // if (row.amount !== '' && row.amount !== null && row.amount !== undefined) {
- // this.postUpdatePramas.name = 'insertPositionPart'
- // // this.postUpdatePramas.parammaps = row
- // this.postUpdatePramas.parammaps = {}
- // this.postUpdatePramas.parammaps.positionId = this.createTemp.id
- // this.postUpdatePramas.parammaps.partId = this.partTemp.partId
- // this.postUpdatePramas.parammaps.note = this.partTemp.note
- // this.postUpdatePramas.parammaps.amount = this.partTemp.amount
- // PostDataByName(this.postUpdatePramas).then(response => {
- // console.log('新增保存发送参数', this.postDataPramas)
- // if (response.msg === 'fail') {
- // this.$notify({
- // title: '保存失败',
- // message: response.data,
- // type: 'warning',
- // duration: 2000
- // })
- // } else {
- // this.getListPart()
- // this.$notify({
- // title: '',
- // message: '保存成功',
- // type: 'success',
- // duration: 2000
- // })
- // }
- // })
- // } else {
- // this.$message({
- // message: '请完善保养内容',
- // type: 'warning',
- // duration: 2000
- // })
- // }
- // },
- // partUpdateDelete(row) {
- // console.log(row)
- // MessageBox.confirm('确认是否删除当前信息?', {
- // confirmButtonText: '确认',
- // cancelButtonText: '取消',
- // type: 'warning'
- // }).then(() => {
- // this.postUpdatePramas.name = 'deletePositionPart'
- // this.postUpdatePramas.parammaps = {}
- // this.postUpdatePramas.parammaps.id = row.id
- // PostDataByName(this.postUpdatePramas).then(response => {
- // console.log('新增保存发送参数', this.postDataPramas)
- // if (response.msg === 'fail') {
- // this.$notify({
- // title: '保存失败',
- // message: response.data,
- // type: 'warning',
- // duration: 2000
- // })
- // } else {
- // this.getListPart()
- // this.$notify({
- // title: '',
- // message: '保存成功',
- // type: 'success',
- // duration: 2000
- // })
- // }
- // })
- // })
- // },
- partUpdateDelete(row) {
- console.log(row)
- MessageBox.confirm('名称:' + row.partName, '确认删除?', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- for (var i = 0; i < this.listAdd.length; i++) {
- console.log(this.listAdd[i])
- if (this.listAdd[i].myid == row.myid) {
- var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
- }
- if (listAddIndex > -1) {
- this.listAdd.splice(listAddIndex, 1)
- return
- }
- }
- })
- },
- sparePartData() {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- console.log(this.listAdd)
- if (this.listAdd.length !== 0) {
- for (var i = 0; i < this.listAdd.length; i++) {
- if (this.listAdd[i].amount == '' || this.listAdd[i].amount == null) {
- this.$message({
- type: 'warning',
- message: '请检查配备数量是否未填写',
- duration: 2000
- })
- return false
- } else {
- var rulesValue = /^\d+(\.\d{1,3})?$/
- if (!rulesValue.test(parseFloat(this.listAdd[i].amount))) {
- this.$message({ type: 'error', message: '配备数量请输入自然数,最多保留两位小数点', duration: 2000 })
- return false
- } else {
- this.postDataPramas.common = { 'returnmap': '0' }
- this.postDataPramas.data = []
- this.postDataPramas.data[0] = { 'name': 'deletePositionpartByPid', 'type': 'e', 'parammaps': {
- positionId: this.createTemp.id
- }}
- // eslint-disable-next-line no-irregular-whitespace
- this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
- this.postDataPramas.data[1].children = []
- this.postDataPramas.data[1].children[0] = { 'name': 'insertPositionPart', 'type': 'e', 'parammaps': {
- positionId: this.createTemp.id,
- note: '@insertSpotList.note',
- partId: '@insertSpotList.partId',
- amount: '@insertSpotList.amount'
- }}
- ExecDataByConfig(this.postDataPramas).then(response => {
- console.log('备件保存发送参数', this.postDataPramas)
- if (response.msg !== 'fail') {
- this.dialogFormVisible = false
- this.getList()
- this.$notify({
- title: '成功',
- message: '新增成功',
- type: 'success',
- duration: 2000
- })
- } else {
- failproccess(response, this.$notify)
- }
- })
- }
- return true
- }
- }
- } else {
- this.$notify({
- title: '',
- message: '请选择备件',
- type: 'warning',
- duration: 2000
- })
- return false
- }
- },
- form_delete(row) {
- MessageBox.confirm('名称:' + row.positionName, '确认删除?', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- this.requestParam.name = 'deletePart'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.id = row.id
- PostDataByName(this.requestParam).then(() => {
- this.getList()
- this.$notify({
- title: '成功',
- message: '删除成功',
- type: 'success',
- duration: 2000
- })
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- // ------------------------------------------------------------------
- jump() {
- this.$router.push('/console/menu')
- }
- }
- }
- </script>
- <style lang="scss">
- .note textarea{
- height: 40px !important;
- line-height: 27px;
- }
- </style>
|