edit.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div>
  3. <el-button size="mini" type="primary" :disabled="disabled" @click="editBtn">编 辑</el-button>
  4. <el-drawer title="新 建" append-to-body :visible.sync="dialogFormVisible" size="30%">
  5. <div slot="title" style="font-size: 15px">
  6. 编辑核销单
  7. </div>
  8. <div class="drawer__panel">
  9. <el-row>
  10. <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="right" size="mini">
  11. <el-col :span="24">
  12. <el-form-item label="经销商:" prop="sys_enterpriseid">
  13. <selectEnterprise ref="ent" @rowClick="entRowClick"></selectEnterprise>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="24">
  17. <el-form-item label="账户类型" prop="sa_accountclassid">
  18. <el-select v-model="form.sa_accountclassid" placeholder="请选择账户类型" @change="accountChange" size="small">
  19. <el-option
  20. v-for="item in accountType"
  21. :key="item.sa_accountclassid"
  22. :label="item.accountname"
  23. :value="item.sa_accountclassid">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="24">
  29. <el-form-item label="凭证" prop="sa_cashbillid">
  30. <selectVoucher ref="voucher" :sys_enterpriseid="form.sys_enterpriseid" :sa_accountclassid="form.sa_accountclassid" @rowClick="voucherRowClick"></selectVoucher>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="24">
  34. <el-form-item label="核销金额" prop="writeoffamount">
  35. <el-input size="small" placeholder="请输入核销金额" v-model.number="form.writeoffamount"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="24">
  39. <el-form-item label="核销日期" prop="billnodate">
  40. <el-date-picker
  41. v-model="form.billnodate"
  42. type="date"
  43. value-format="yy-mm-dd"
  44. placeholder="选择日期">
  45. </el-date-picker>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="24">
  49. <el-form-item label="备注" prop="remarks">
  50. <el-input size="small" type="textarea" placeholder="请输入备注" v-model.number="form.remarks"></el-input>
  51. </el-form-item>
  52. </el-col>
  53. </el-form>
  54. </el-row>
  55. </div>
  56. <div class="fixed__btn__panel">
  57. <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
  58. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  59. </div>
  60. </el-drawer>
  61. </div>
  62. </template>
  63. <script>
  64. import selectEnterprise from './selectEnterprise'
  65. import selectVoucher from './selectVoucher'
  66. export default {
  67. name: "add",
  68. props:['data','disabled'],
  69. components:{selectEnterprise,selectVoucher},
  70. data(){
  71. return {
  72. dialogFormVisible:false,
  73. accountType:[],
  74. form:{
  75. "sa_writeoffbillid":0,
  76. "sys_enterpriseid": "",
  77. "sa_accountclassid": "",
  78. "sa_cashbillid":"",
  79. "remarks":"",
  80. "writeoffamount":'', //新增时可不传
  81. "billnodate":''
  82. },
  83. rules:{
  84. sys_enterpriseid:[
  85. { required: true, message: '请选择经销商', trigger: 'blur'},
  86. ],
  87. sa_accountclassid:[
  88. { required: true, message: '请选择账户类型', trigger: 'blur'}
  89. ],
  90. sa_cashbillid:[
  91. { required: true, message: '请选择支出或收入凭证', trigger: 'blur'}
  92. ],
  93. writeoffamount:[
  94. { message: '请填写正确金额', trigger: 'change',type:'number'}
  95. ],
  96. }
  97. }
  98. },
  99. created () {
  100. this.getAccountType()
  101. },
  102. watch: {
  103. dialogFormVisible (val) {
  104. if(!val) {
  105. this.$refs.ent.form.enterprisename = ''
  106. this.$refs.form.resetFields()
  107. }
  108. }
  109. },
  110. methods:{
  111. editBtn () {
  112. this.form = Object.assign({},this.form,this.data)
  113. console.log(this.form);
  114. this.$nextTick(() => {
  115. this.$refs.ent.form.enterprisename = this.form.enterprisename
  116. this.$refs.voucher.form.billno = this.form.cashbillidbillno
  117. console.log(this.$refs.ent.form);
  118. })
  119. this.dialogFormVisible = true
  120. },
  121. onSubmit(){
  122. console.log(this.form)
  123. this.$refs['form'].validate(async (valid) => {
  124. if (!valid) return false
  125. const res = await this.$api.requested({
  126. "id": "20221124090204",
  127. "version":1,
  128. "content": this.form
  129. })
  130. this.tool.showMessage(res,()=>{
  131. this.$emit('onSuccess')
  132. this.dialogFormVisible = false
  133. })
  134. })
  135. },
  136. entRowClick (data) {
  137. this.$refs.voucher.form.billno = ''
  138. this.form.sa_cashbillid = ''
  139. this.form.sys_enterpriseid = data.sys_enterpriseid
  140. },
  141. voucherRowClick (data) {
  142. this.form.sa_cashbillid = data.sa_cashbillid
  143. },
  144. async getAccountType () {
  145. let res = await this.$api.requested({
  146. "id":20221124090604,
  147. "content": {
  148. }
  149. })
  150. this.accountType = res.data
  151. console.log(this.accountType);
  152. },
  153. accountChange (val) {
  154. this.$refs.voucher.form.billno = ''
  155. this.form.sa_cashbillid = ''
  156. }
  157. }
  158. }
  159. </script>
  160. <style scoped>
  161. .dialog-footer {
  162. margin-top: 0;
  163. }
  164. .el-select {
  165. width: 100%;
  166. }
  167. /deep/.el-date-editor {
  168. width: 100% !important;
  169. }
  170. </style>