add.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <el-button size="mini" type="primary" @click="dialogFormVisible = true;form.billnodate=new Date()">新 建</el-button>
  4. <el-drawer title="新建核销单" append-to-body :show-close="false" :visible.sync="dialogFormVisible" size="60%">
  5. <div class="drawer__panel">
  6. <el-row>
  7. <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="right" size="mini">
  8. <el-col :span="12">
  9. <el-form-item label="经销商:" prop="sys_enterpriseid">
  10. <selectEnterprise ref="ent" @rowClick="entRowClick"></selectEnterprise>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="12">
  14. <el-form-item label="账户类型" prop="sa_accountclassid">
  15. <el-select v-model="form.sa_accountclassid" placeholder="请选择账户类型" @change="accountChange" size="small">
  16. <el-option
  17. v-for="item in accountType"
  18. :key="item.sa_accountclassid"
  19. :label="item.accountname"
  20. :value="item.sa_accountclassid">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="12">
  26. <el-form-item label="凭证" prop="sa_cashbillid">
  27. <selectVoucher ref="voucher" v-model="form.sa_cashbillid" :sys_enterpriseid="form.sys_enterpriseid" :sa_accountclassid="form.sa_accountclassid" @rowClick="voucherRowClick"></selectVoucher>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="12">
  31. <el-form-item label="核销金额" prop="writeoffamount">
  32. <el-input size="small" placeholder="请输入核销金额" v-model.number="form.writeoffamount"></el-input>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="12">
  36. <el-form-item label="核销日期" prop="billnodate">
  37. <el-date-picker
  38. v-model="form.billnodate"
  39. type="date"
  40. value-format="yyyy-MM-dd"
  41. placeholder="选择日期">
  42. </el-date-picker>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="24">
  46. <el-form-item label="订单">
  47. <div class="flex-align-center flex-between mt-10">
  48. <el-input
  49. style="width:200px"
  50. size="small"
  51. suffix-icon="el-icon-search"
  52. v-model="params.content.where.condition" placeholder="搜索"
  53. @keyup.enter.native="getOrderList(params.content.pageNumber = 1)" @clear="getOrderList(params.content.pageNumber = 1)" clearable></el-input>
  54. </div>
  55. <selectOrder v-if="dialogFormVisible" ref="table" idName="sa_orderitemsid" :layout="tablecols" :data="orderList" :custom="true" height="500px">
  56. <template v-slot:customcol="scope">
  57. <div>{{scope.column.data[scope.column.columnname]}}</div>
  58. </template>
  59. </selectOrder>
  60. <div class="container normal-panel" style="text-align:right">
  61. <el-pagination
  62. style="text-align:right"
  63. background
  64. small
  65. @size-change="handleSizeChange"
  66. @current-change="handleCurrentChange"
  67. :current-page="params.content.pageNumber"
  68. :page-size="params.content.pageSize"
  69. layout="total,sizes, prev, pager, next, jumper"
  70. :total="total">
  71. </el-pagination>
  72. </div>
  73. </el-form-item>
  74. </el-col>
  75. </el-form>
  76. </el-row>
  77. </div>
  78. <div class="fixed__btn__panel">
  79. <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
  80. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  81. </div>
  82. </el-drawer>
  83. </div>
  84. </template>
  85. <script>
  86. import selectEnterprise from './selectEnterprise'
  87. import selectVoucher from './selectVoucher'
  88. import selectOrder from '../modules/order/selectOrder'
  89. export default {
  90. name: "add",
  91. components:{selectEnterprise,selectVoucher,selectOrder},
  92. data(){
  93. return {
  94. dialogFormVisible:false,
  95. accountType:[],
  96. tablecols:[],
  97. total:0,
  98. orderList:[],
  99. form:{
  100. "sa_writeoffbillid":0,
  101. "sys_enterpriseid": "",
  102. "sa_accountclassid": "",
  103. "sa_cashbillid":"",
  104. "remarks":"",
  105. "writeoffamount":0, //新增时可不传
  106. "billnodate": ''
  107. },
  108. rules:{
  109. sys_enterpriseid:[
  110. { required: true, message: '请选择经销商', trigger: 'blur'},
  111. ],
  112. sa_accountclassid:[
  113. { required: true, message: '请选择账户类型', trigger: 'blur'}
  114. ],
  115. sa_cashbillid:[
  116. { required: true, message: '请选择支出或收入凭证', trigger: 'change'}
  117. ],
  118. writeoffamount:[
  119. { message: '请填写正确金额', trigger: 'blur',type:'number'}
  120. ],
  121. },
  122. params: {
  123. "id": 20221124091104,
  124. "content": {
  125. "pageNumber": 1,
  126. "pageSize": 20,
  127. "sys_enterpriseid":'',
  128. "sa_accountclassid":'',
  129. "sa_writeoffbillid":'',
  130. "where": {
  131. "condition": ""
  132. }
  133. }
  134. }
  135. }
  136. },
  137. created () {
  138. this.getAccountType()
  139. this.tablecols = this.tool.tabelCol(this.$route.name).addOrderTable.tablecols
  140. },
  141. watch: {
  142. dialogFormVisible (val) {
  143. if(!val) {
  144. this.$refs.ent.form.enterprisename = ''
  145. this.$refs.form.resetFields()
  146. this.$refs.table.allArr = []
  147. this.orderList = []
  148. this.$refs.voucher.form.billno = ''
  149. this.form.sa_cashbillid = ''
  150. }
  151. }
  152. },
  153. methods:{
  154. handleSizeChange(val) {
  155. // console.log(`每页 ${val} 条`);
  156. this.params.content.pageSize = val
  157. this.getOrderList()
  158. },
  159. handleCurrentChange(val) {
  160. // console.log(`当前页: ${val}`);
  161. this.params.content.pageNumber = val
  162. this.getOrderList()
  163. },
  164. async getOrderList () {
  165. if(!this.form.sa_accountclassid || !this.form.sys_enterpriseid) return
  166. this.$refs.table.allArr = []
  167. this.params.content.sys_enterpriseid = this.form.sys_enterpriseid
  168. this.params.content.sa_accountclassid = this.form.sa_accountclassid
  169. let res = await this.$api.requested(this.params)
  170. this.orderList = res.data
  171. this.total = res.total
  172. console.log(res);
  173. },
  174. onSubmit(){
  175. console.log(this.form)
  176. this.$refs['form'].validate(async (valid) => {
  177. if (!valid) return false
  178. const res = await this.$api.requested({
  179. "id": "20221124090204",
  180. "version":1,
  181. "content": this.form
  182. })
  183. this.tool.showMessage(res,async ()=>{
  184. let result = this.$refs.table.allArr.map(item => {
  185. return {
  186. "sa_writeoffbill_orderid": 0,
  187. "sa_orderid":item.sa_orderid,
  188. "sa_orderitemsid":item.sa_orderitemsid,
  189. "writeoffamount":0,
  190. "remarks":""
  191. }
  192. })
  193. if (result.length > 0) {
  194. const res2 = await this.$api.requested({
  195. "id": "20221124090904",
  196. "version":1,
  197. "content": {
  198. sa_writeoffbillid:res.data[0].sa_writeoffbillid,
  199. writeoffbillOrder:result
  200. }
  201. })
  202. }
  203. this.$emit('onSuccess')
  204. this.dialogFormVisible = false
  205. })
  206. })
  207. },
  208. entRowClick (data) {
  209. this.$refs.voucher.form.billno = ''
  210. this.form.sa_cashbillid = ''
  211. this.form.sys_enterpriseid = data.sys_enterpriseid
  212. this.getOrderList()
  213. },
  214. voucherRowClick (data) {
  215. this.form.sa_cashbillid = data.sa_cashbillid
  216. },
  217. async getAccountType () {
  218. let res = await this.$api.requested({
  219. "id":20221124090604,
  220. "content": {
  221. }
  222. })
  223. this.accountType = res.data
  224. },
  225. accountChange (val) {
  226. this.$refs.voucher.form.billno = ''
  227. this.form.sa_cashbillid = ''
  228. this.getOrderList()
  229. }
  230. }
  231. }
  232. </script>
  233. <style scoped>
  234. .dialog-footer {
  235. margin-top: 0;
  236. }
  237. .el-select {
  238. width: 100%;
  239. }
  240. </style>