edit.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div>
  3. <el-button size="mini" type="text" @click="onShow">编 辑</el-button>
  4. <el-dialog title="编 辑" :visible.sync="dialogFormVisible">
  5. <el-row :gutter="20">
  6. <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="left" size="mini">
  7. <el-col :span="24">
  8. <el-form-item label="企业名称" prop="sys_enterpriseid">
  9. <el-select v-model="form.sys_enterpriseid" placeholder="请选择企业" @change="enterpriseChange">
  10. <el-option
  11. v-for="item in enterpriseData"
  12. :key="item.sys_enterpriseid"
  13. :label="item.enterprisename"
  14. :value="item.sys_enterpriseid">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="12">
  20. <el-form-item label="账户类型" prop="sa_accountclassid">
  21. <el-select v-model="form.sa_accountclassid" placeholder="请选择账户类型">
  22. <el-option
  23. v-for="item in accountClassData"
  24. :key="item.sa_accountclassid"
  25. :label="item.accountname"
  26. :value="item.sa_accountclassid">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="12">
  32. <el-form-item label="信用额度" prop="creditquota">
  33. <el-input v-model="form.creditquota" placeholder="输入信用额度"></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="14">
  37. <el-form-item label="备注" prop="address">
  38. <el-input v-model="form.address" type="textarea" :rows="3" placeholder="输入备注"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. </el-form>
  42. </el-row>
  43. <div class="dialog-footer">
  44. <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
  45. <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
  46. </div>
  47. </el-dialog>
  48. </div>
  49. </template>
  50. <script>
  51. import {mapGetters} from 'vuex'
  52. export default {
  53. props:['data'],
  54. data () {
  55. return {
  56. dialogFormVisible:false,
  57. enterpriseData:[],
  58. accountClassData:[],
  59. form:{
  60. sa_creditbillid:0,
  61. sys_enterpriseid:'',
  62. sa_accountclassid:'',
  63. creditquota:'',
  64. remarks:''
  65. },
  66. rules:{
  67. sys_enterpriseid: [
  68. { required: true, message: '请选择企业名称', trigger: 'blur' },
  69. ],
  70. sa_accountclassid: [
  71. { required: true, message: '请选择账户类型', trigger: 'blur' },
  72. ],
  73. creditquota: [
  74. { required: true, message: '请填写信用额度', trigger: 'change' },
  75. ],
  76. }
  77. }
  78. },
  79. methods:{
  80. /* 获取企业档案 */
  81. async getEnterpriseData() {
  82. let res = await this.$api.requested({
  83. "id": "20221008164103",
  84. "version":1,
  85. "content": {
  86. "where":{
  87. "condition":""
  88. }
  89. }
  90. })
  91. this.enterpriseData = res.data
  92. console.log(this.enterpriseData);
  93. },
  94. /* 企业选择变化 */
  95. async enterpriseChange() {
  96. console.log(this.form.sys_enterpriseid);
  97. let res = await this.$api.requested({
  98. "id": "20221008164203",
  99. "version":1,
  100. "content": {
  101. "sys_enterpriseid":this.form.sys_enterpriseid
  102. }
  103. })
  104. this.form.sa_accountclassid = ''
  105. this.accountClassData = res.data
  106. console.log(this.accountClassData);
  107. },
  108. cascaderChange (val) {
  109. if (val.length === 1)
  110. return this.form = Object.assign({},this.form,{province:val[0],city:'',county:''})
  111. this.form = Object.assign({},this.form,{province:val[0],city:val[1],county:val[2]})
  112. },
  113. onSubmit () {
  114. this.$refs['form'].validate(async (valid) => {
  115. if (!valid) return false
  116. const res = await this.$api.requested({
  117. "id": "20221008155003",
  118. "version":1,
  119. "content": this.form
  120. })
  121. this.tool.showMessage(res,()=>{
  122. this.$emit('onSuccess')
  123. this.$refs['form'].resetFields();
  124. this.dialogFormVisible = false
  125. })
  126. })
  127. },
  128. async onShow () {
  129. this.form = Object.assign({},this.form,this.data)
  130. console.log(this.form);
  131. if( this.data ) {
  132. let res = await this.$api.requested({
  133. "id": "20221008164203",
  134. "version":1,
  135. "content": {
  136. "sys_enterpriseid":this.form.sys_enterpriseid
  137. }
  138. })
  139. this.accountClassData = res.data
  140. }
  141. this.dialogFormVisible = true
  142. }
  143. },
  144. created() {
  145. this.getEnterpriseData()
  146. },
  147. mounted () {
  148. }
  149. }
  150. </script>
  151. <style scoped>
  152. /deep/.el-select {
  153. width: 100% !important;
  154. }
  155. </style>