add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" @click="onShow">新 增</el-button>
  4. <el-drawer
  5. title="新增返利代金券支出"
  6. :visible.sync="dialogFormVisible"
  7. size="40%"
  8. direction="rtl"
  9. :show-close="false"
  10. append-to-body
  11. @close="onClose(dialogFormVisible = false)">
  12. <div class="drawer__panel">
  13. <el-row :gutter="20">
  14. <el-form :model="form" :rules="rules" ref="form" label-width="100px" label-position="right" size="mini">
  15. <el-col :span="12">
  16. <el-form-item label="企业名称:" prop="enterprisename">
  17. <el-popover
  18. placement="bottom"
  19. width="700"
  20. trigger="click"
  21. v-model="enterpriseShow"
  22. @show="queryEnterprise">
  23. <el-input
  24. style="width:300px;margin-bottom: 10px"
  25. :suffix-icon="enterpriseParam.content.where.condition?enterpriseParam.content.where.condition.length > 0?'':'':'el-icon-search'"
  26. placeholder="请输入内容"
  27. v-model="enterpriseParam.content.where.condition"
  28. clearable
  29. @clear="queryEnterprise(enterpriseParam.content.pageNumber = 1)"
  30. size="mini"
  31. @keyup.enter.native="queryEnterprise(enterpriseParam.content.pageNumber = 1)">
  32. </el-input>
  33. <el-table :data="enterprise.enterpriseData" @row-click="enterpriseData" height="396px" border size="mini">
  34. <el-table-column
  35. label="企业名称"
  36. width="180">
  37. <template slot-scope="scope">
  38. <span style="margin-left: 10px">{{ scope.row.enterprisename?scope.row.enterprisename:'--' }}</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column
  42. label="省市县"
  43. width="180">
  44. <template slot-scope="scope">
  45. <span style="margin-left: 10px">{{ scope.row.province?scope.row.province + '-' + scope.row.city + '-' + scope.row.county:'--' }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column
  49. label="详细地址"
  50. width="0">
  51. <template slot-scope="scope">
  52. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <div class="container normal-panel" style="text-align:right">
  57. <el-pagination
  58. background
  59. small
  60. @size-change="handleSizeChange"
  61. @current-change="handleCurrentChange"
  62. :page-sizes="[20,50,100,]"
  63. layout="total,sizes, prev, pager, next, jumper"
  64. :current-page="enterprise.currentPage"
  65. :total="enterprise.total">
  66. </el-pagination>
  67. </div>
  68. <el-input slot="reference" :readonly="true" v-model="form.enterprisename" autocomplete="off" placeholder="请选择企业" ></el-input>
  69. </el-popover>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12" >
  73. <el-form-item label="分类明细:" prop="subclass">
  74. <el-select v-model="form.subclass" placeholder="请选择分类明细" style="width: 100%">
  75. <el-option
  76. v-for="item in subClassData"
  77. :key="item.value"
  78. :label="item.value"
  79. :value="item.value">
  80. </el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="12">
  85. <el-form-item label="单据日期:" prop="billdate">
  86. <el-date-picker
  87. style="width: 100%"
  88. v-model="form.billdate"
  89. format="yyyy-MM-dd"
  90. value-format="yyyy-MM-dd"
  91. type="date"
  92. placeholder="选择日期">
  93. </el-date-picker>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="12">
  97. <el-form-item label="返利代金券:" prop="sa_cashbillid_rebate">
  98. <el-popover
  99. placement="bottom"
  100. width="700"
  101. trigger="click"
  102. v-model="cashCouponShow"
  103. @show="queryCashCoupon">
  104. <el-input
  105. style="width:300px;margin-bottom: 10px"
  106. placeholder="请输入内容"
  107. v-model="cashCouponParam.content.where.condition"
  108. clearable
  109. @clear="queryCashCoupon(cashCouponParam.content.pageNumber = 1)"
  110. size="mini"
  111. @keyup.enter.native="queryCashCoupon(cashCouponParam.content.pageNumber = 1)">
  112. <i slot="prefix" class="el-icon-search" @click="queryCashCoupon(cashCouponParam.content.pageNumber = 1)"></i>
  113. </el-input>
  114. <el-table :data="cashCoupon.cashCouponData" @row-click="cashCouponData" height="396px" border size="mini">
  115. <el-table-column
  116. label="单号"
  117. width="180">
  118. <template slot-scope="scope">
  119. <span style="margin-left: 10px">{{ scope.row.billno?scope.row.billno:'--' }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. label="金额"
  124. width="180">
  125. <template slot-scope="scope">
  126. <span style="margin-left: 10px">{{ scope.row.amount?scope.row.amount:'--' }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column
  130. label="分类明细"
  131. >
  132. <template slot-scope="scope">
  133. <span style="margin-left: 10px">{{ scope.row.subclass?scope.row.subclass:'--' }}</span>
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. label="单据时间"
  138. >
  139. <template slot-scope="scope">
  140. <span style="margin-left: 10px">{{ scope.row.billdate?scope.row.billdate:'--' }}</span>
  141. </template>
  142. </el-table-column>
  143. </el-table>
  144. <div class="container normal-panel" style="text-align:right">
  145. <el-pagination
  146. background
  147. small
  148. @size-change="handleSizeChangeCashCoupon"
  149. @current-change="handleCurrentChangeCashCoupon"
  150. :page-sizes="[10,20,50,100,]"
  151. layout="total,sizes, prev, pager, next, jumper"
  152. :current-page="cashCoupon.currentPage"
  153. :total="cashCoupon.total">
  154. </el-pagination>
  155. </div>
  156. <el-input slot="reference" :readonly="true" v-model="form.sa_cashbillid_billno" autocomplete="off" placeholder="请选择返利代金券" ></el-input>
  157. </el-popover>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="12">
  161. <el-form-item label="支出金额:" prop="amount">
  162. <el-input v-model="form.amount" placeholder="请输入金额" type="number"></el-input>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="24">
  166. <el-form-item label="备注:" prop="remarks">
  167. <el-input v-model="form.remarks" type="textarea" rows="5" placeholder="请输入备注信息"></el-input>
  168. </el-form-item>
  169. </el-col>
  170. </el-form>
  171. </el-row>
  172. </div>
  173. <div class="fixed__btn__panel">
  174. <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
  175. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  176. </div>
  177. </el-drawer>
  178. </div>
  179. </template>
  180. <script>
  181. export default {
  182. name: "add",
  183. data() {
  184. var amountData = (rule,value,callback) =>{
  185. if (this.form.amount < 0 ){
  186. callback(new Error('不能下于0'))
  187. }else if(this.form.amount > this.cashCouponAmount){
  188. callback(new Error('不能超过代金券可用金额'))
  189. }
  190. else {
  191. callback();
  192. }
  193. }
  194. return {
  195. dialogFormVisible:false,
  196. enterpriseShow:false,
  197. cashCouponShow:false,
  198. cashCouponAmount:'',
  199. form:{
  200. "sa_cashbillid": 0,
  201. "sys_enterpriseid": '', //合作企业档案ID
  202. "remarks": "",
  203. "subclass": "", //明细分类
  204. "amount": '', //金额
  205. "billdate": "", //单据日期
  206. "enterprisename":"",
  207. "sa_cashbillid_rebate": '', //所选的代金券id
  208. "sa_cashbillid_billno":""
  209. },
  210. rules:{
  211. enterprisename:[
  212. { required: true, message: '请选择企业', trigger: 'change'},
  213. ],
  214. subclass:[
  215. { required: true, message: '请选择分类明细', trigger: 'change'},
  216. ],
  217. amount:[
  218. { required: true, validator: amountData, trigger: 'blur'},
  219. ],
  220. sa_cashbillid_rebate:[
  221. { required: true, message: '请选择返利代金券', trigger: 'change'},
  222. ],
  223. },
  224. subClassData:[],
  225. enterpriseParam:{
  226. content: {
  227. pageNumber: 1,
  228. pageSize: 20,
  229. where: {
  230. condition: "",
  231. type: 1,
  232. sa_projectid: ""
  233. }
  234. },
  235. id: 20220920083901
  236. },
  237. enterprise:{
  238. enterpriseData:[],
  239. total:0,
  240. currentPage:0,
  241. },
  242. cashCouponParam:{
  243. "id": 20230216192902,
  244. "content": {
  245. // "sys_enterpriseid": 2, //不传查全部,
  246. "pageNumber": 1,
  247. "pageSize": 20,
  248. "where": {
  249. "condition": "",
  250. "status": "审核"
  251. }
  252. }
  253. },
  254. cashCoupon:{
  255. cashCouponData:[],
  256. total:0,
  257. currentPage:0,
  258. }
  259. }
  260. },
  261. methods:{
  262. onSubmit(){
  263. console.log(this.form)
  264. this.$refs.form.validate(async(valid) => {
  265. if (!valid) return false
  266. const res = await this.$api.requested({
  267. "id": 20230302140402,
  268. "content": this.form
  269. })
  270. this.tool.showMessage(res,()=>{
  271. this.$emit('onSuccess')
  272. this.dialogFormVisible = false
  273. this.$refs.form.resetFields()
  274. this.form = {
  275. "sa_cashbillid": 0,
  276. "sys_enterpriseid": '', //合作企业档案ID
  277. "remarks": "",
  278. "subclass": "", //明细分类
  279. "amount": '', //金额
  280. "billdate": "", //单据日期
  281. "enterprisename":"",
  282. "sa_cashbillid_rebate": '', //所选的代金券id
  283. "sa_cashbillid_billno":""
  284. }
  285. this.$store.dispatch('changeDetailDrawer',true)
  286. this.$router.push({path:'/cashcouponPayDetail',query:{id:res.data.sa_cashbillid,rowindex:res.data.rowindex}})
  287. })
  288. })
  289. },
  290. onShow(){
  291. this.dialogFormVisible = true
  292. const newData = new Date()
  293. console.log(newData.getMonth())
  294. this.form.billdate = newData.getFullYear() + '-' + ((newData.getMonth() + 1) < 10? '0'+(newData.getMonth() + 1): (newData.getMonth() + 1)) + '-' + newData.getDate()
  295. this.subClassList()
  296. },
  297. /*获取分类明细*/
  298. subClassList(){
  299. this.$store.dispatch('optiontypeselect','rebatepaytype').then(res=>{
  300. console.log(res,'分类明细')
  301. /*let index = ''
  302. for (var i = 0 ;i<res.data.length; i++){
  303. if (res.data[i].value === '返利金'){
  304. index = i
  305. }
  306. }*/
  307. this.subClassData = res.data
  308. })
  309. },
  310. /*获取企业*/
  311. async queryEnterprise(){
  312. const res = await this.$api.requested(this.enterpriseParam)
  313. this.enterprise.enterpriseData = res.data
  314. this.enterprise.total = res.total
  315. this.enterprise.currentPage = res.pageNumber
  316. },
  317. enterpriseData(row){
  318. console.log(row,'row')
  319. this.form.sys_enterpriseid = row.sys_enterpriseid
  320. this.form.enterprisename = row.enterprisename
  321. this.enterpriseShow = false
  322. },
  323. handleSizeChange(val) {
  324. // console.log(`每页 ${val} 条`);
  325. this.enterpriseParam.content.pageSize = val
  326. this.queryEnterprise()
  327. },
  328. handleCurrentChange(val) {
  329. // console.log(`当前页: ${val}`);
  330. this.enterpriseParam.content.pageNumber = val
  331. this.queryEnterprise()
  332. },
  333. /*获取返利代金券*/
  334. async queryCashCoupon(){
  335. this.cashCouponParam.content.where.condition = this.form.enterprisename
  336. const res = await this.$api.requested(this.cashCouponParam)
  337. this.cashCoupon.cashCouponData = res.data
  338. this.cashCoupon.total = res.total
  339. this.cashCoupon.currentPage = res.pageNumber
  340. },
  341. cashCouponData(row){
  342. console.log(row)
  343. this.form.sa_cashbillid_billno = row.billno
  344. this.form.sa_cashbillid_rebate = row.sa_cashbillid
  345. this.cashCouponAmount = row.amount
  346. this.cashCouponShow = false
  347. },
  348. handleSizeChangeCashCoupon(val) {
  349. // console.log(`每页 ${val} 条`);
  350. this.enterpriseParam.content.pageSize = val
  351. this.queryCashCoupon()
  352. },
  353. handleCurrentChangeCashCoupon(val) {
  354. // console.log(`当前页: ${val}`);
  355. this.enterpriseParam.content.pageNumber = val
  356. this.queryCashCoupon()
  357. },
  358. onClose(){
  359. this.$refs.form.resetFields()
  360. this.form = {
  361. "sa_cashbillid": 0,
  362. "sys_enterpriseid": '', //合作企业档案ID
  363. "remarks": "",
  364. "subclass": "", //明细分类
  365. "amount": '', //金额
  366. "billdate": "", //单据日期
  367. "enterprisename":"",
  368. "sa_cashbillid_rebate": '', //所选的代金券id
  369. "sa_cashbillid_billno":""
  370. }
  371. }
  372. }
  373. }
  374. </script>
  375. <style scoped>
  376. </style>