You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.7 KiB

  1. <template>
  2. <div>
  3. <el-dialog
  4. width="340px"
  5. @close="closeDialog"
  6. :title="!this.addOrUpdate ? '新增' : '修改'"
  7. :close-on-click-modal="false"
  8. :visible.sync="visible">
  9. <el-form :model="dataForm" label-position="top" :inline="true" ref="dataForm"
  10. @keyup.enter.native="dataFormSubmit()"
  11. label-width="120px">
  12. <el-form-item required>
  13. <el-link @click="getBaseList(113)" slot="label">设备编码</el-link>
  14. <el-input v-model="dataForm.resourceId"></el-input>
  15. </el-form-item>
  16. <el-form-item label="设备名称">
  17. <el-input disabled v-model="dataForm.resourceName"></el-input>
  18. </el-form-item>
  19. <el-form-item required>
  20. <el-link @click="getBaseList(114)" slot="label">备品备件编码</el-link>
  21. <el-input v-model="dataForm.partNo"></el-input>
  22. </el-form-item>
  23. <el-form-item label="备品备件名称">
  24. <el-input disabled v-model="dataForm.partDesc"></el-input>
  25. </el-form-item>
  26. <el-form-item required label="可用数量">
  27. <el-input-number style="width: 146px" :min="0" v-model="dataForm.qtyUsable"></el-input-number>
  28. </el-form-item>
  29. </el-form>
  30. <span slot="footer" class="dialog-footer">
  31. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  32. <el-button type="primary" @click="visible = false">取消</el-button>
  33. </span>
  34. </el-dialog>
  35. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  36. </div>
  37. </template>
  38. <script>
  39. import Chooselist from '@/views/modules/common/Chooselist_eam'
  40. import {getResourceSpareInfo, saveResourceSpare, updateResourceSpare} from '@/api/partspare/resourcespare.js'
  41. export default {
  42. data() {
  43. return {
  44. visible: false,
  45. dataForm: {
  46. id: 0,
  47. resourceId: '',
  48. resourceIdOld: '',
  49. resourceName: '',
  50. partNo: '',
  51. partNoOld: '',
  52. partDesc: '',
  53. qtyUsable: '',
  54. delflag: '',
  55. createdBy: '',
  56. site: this.$store.state.user.site
  57. },
  58. addOrUpdate: false,
  59. }
  60. },
  61. components: {
  62. Chooselist
  63. },
  64. methods: {
  65. // 获取基础数据列表S
  66. getBaseList(val, type) {
  67. this.tagNo = val
  68. this.$nextTick(() => {
  69. let strVal = ''
  70. let conSql = ''
  71. if (val === 113) {
  72. strVal = this.dataForm.resourceId
  73. }
  74. if (val === 114) {
  75. strVal = this.dataForm.partNo
  76. }
  77. this.$refs.baseList.init(val, strVal, conSql)
  78. })
  79. },
  80. /* 列表方法的回调 */
  81. getBaseData(val) {
  82. if (this.tagNo === 113) {
  83. this.dataForm.resourceId = val.ObjectID
  84. this.dataForm.resourceName = val.ObjectDesc
  85. }
  86. if (this.tagNo === 114) {
  87. this.dataForm.partNo = val.part_no
  88. this.dataForm.partDesc = val.part_description
  89. }
  90. },
  91. init(row) {
  92. this.addOrUpdate = row ? true : false
  93. this.visible = true
  94. this.$nextTick(() => {
  95. if (this.addOrUpdate) {
  96. this.dataForm.site = row.site
  97. this.dataForm.resourceId = row.resourceId
  98. this.dataForm.partNo = row.partNo
  99. getResourceSpareInfo(this.dataForm).then(({data}) => {
  100. if (data && data.code === 0) {
  101. this.dataForm.resourceId = data.resourceSpare.resourceId
  102. this.dataForm.resourceName = data.resourceSpare.resourceDesc
  103. this.dataForm.partNo = data.resourceSpare.partNo
  104. this.dataForm.partDesc = data.resourceSpare.partDescription
  105. this.dataForm.site = data.resourceSpare.site
  106. this.dataForm.qtyUsable = data.resourceSpare.qtyUsable
  107. this.dataForm.resourceIdOld = data.resourceSpare.resourceId
  108. this.dataForm.partNoOld = data.resourceSpare.partNo
  109. }
  110. })
  111. }
  112. })
  113. },
  114. // 表单提交
  115. dataFormSubmit() {
  116. if (this.addOrUpdate) {
  117. updateResourceSpare(this.dataForm).then(({data}) => {
  118. if (data && data.code === 0) {
  119. this.$message.success(data.msg)
  120. this.visible = false
  121. this.$emit('refreshDataList')
  122. } else {
  123. this.$message.error(data.msg)
  124. }
  125. })
  126. } else {
  127. saveResourceSpare(this.dataForm).then(({data}) => {
  128. if (data && data.code === 0) {
  129. this.$message.success(data.msg)
  130. this.visible = false
  131. this.$emit('refreshDataList')
  132. } else {
  133. this.$message.error(data.msg)
  134. }
  135. })
  136. }
  137. },
  138. closeDialog() {
  139. this.$nextTick(() => {
  140. this.$emit('refreshDataList')
  141. Object.assign(this.$data, this.$options.data.call(this));
  142. })
  143. },
  144. }
  145. }
  146. </script>