add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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 > this.cashCouponAmount){
  186. callback(new Error('不能超过代金券可用金额'))
  187. }
  188. else {
  189. callback();
  190. }
  191. }
  192. return {
  193. dialogFormVisible:false,
  194. enterpriseShow:false,
  195. cashCouponShow:false,
  196. cashCouponAmount:'',
  197. form:{
  198. "sa_cashbillid": 0,
  199. "sys_enterpriseid": '', //合作企业档案ID
  200. "remarks": "",
  201. "subclass": "", //明细分类
  202. "amount": '', //金额
  203. "billdate": "", //单据日期
  204. "enterprisename":"",
  205. "sa_cashbillid_rebate": '', //所选的代金券id
  206. "sa_cashbillid_billno":""
  207. },
  208. rules:{
  209. enterprisename:[
  210. { required: true, message: '请选择企业', trigger: 'change'},
  211. ],
  212. subclass:[
  213. { required: true, message: '请选择分类明细', trigger: 'change'},
  214. ],
  215. amount:[
  216. { required: true, validator: amountData, trigger: 'blur'},
  217. ],
  218. sa_cashbillid_rebate:[
  219. { required: true, message: '请选择返利代金券', trigger: 'change'},
  220. ],
  221. },
  222. subClassData:[],
  223. enterpriseParam:{
  224. content: {
  225. pageNumber: 1,
  226. pageSize: 20,
  227. where: {
  228. condition: "",
  229. type: 1,
  230. sa_projectid: ""
  231. }
  232. },
  233. id: 20220920083901
  234. },
  235. enterprise:{
  236. enterpriseData:[],
  237. total:0,
  238. currentPage:0,
  239. },
  240. cashCouponParam:{
  241. "id": 20230216192902,
  242. "content": {
  243. // "sys_enterpriseid": 2, //不传查全部,
  244. "pageNumber": 1,
  245. "pageSize": 20,
  246. "where": {
  247. "condition": "",
  248. "status": "审核"
  249. }
  250. }
  251. },
  252. cashCoupon:{
  253. cashCouponData:[],
  254. total:0,
  255. currentPage:0,
  256. }
  257. }
  258. },
  259. methods:{
  260. onSubmit(){
  261. console.log(this.form)
  262. this.$refs.form.validate(async(valid) => {
  263. if (!valid) return false
  264. const res = await this.$api.requested({
  265. "id": 20230302140402,
  266. "content": this.form
  267. })
  268. this.tool.showMessage(res,()=>{
  269. this.$emit('onSuccess')
  270. this.dialogFormVisible = false
  271. this.$refs.form.resetFields()
  272. this.form = {
  273. "sa_cashbillid": 0,
  274. "sys_enterpriseid": '', //合作企业档案ID
  275. "remarks": "",
  276. "subclass": "", //明细分类
  277. "amount": '', //金额
  278. "billdate": "", //单据日期
  279. "enterprisename":"",
  280. "sa_cashbillid_rebate": '', //所选的代金券id
  281. "sa_cashbillid_billno":""
  282. }
  283. this.$store.dispatch('changeDetailDrawer',true)
  284. this.$router.push({path:'/cashcouponPayDetail',query:{id:res.data.sa_cashbillid,rowindex:res.data.rowindex}})
  285. })
  286. })
  287. },
  288. onShow(){
  289. this.dialogFormVisible = true
  290. const newData = new Date()
  291. console.log(newData.getMonth())
  292. this.form.billdate = newData.getFullYear() + '-' + ((newData.getMonth() + 1) < 10? '0'+(newData.getMonth() + 1): (newData.getMonth() + 1)) + '-' + newData.getDate()
  293. this.subClassList()
  294. },
  295. /*获取分类明细*/
  296. subClassList(){
  297. this.$store.dispatch('optiontypeselect','rebatepaytype').then(res=>{
  298. console.log(res,'分类明细')
  299. /*let index = ''
  300. for (var i = 0 ;i<res.data.length; i++){
  301. if (res.data[i].value === '返利金'){
  302. index = i
  303. }
  304. }*/
  305. this.subClassData = res.data
  306. })
  307. },
  308. /*获取企业*/
  309. async queryEnterprise(){
  310. const res = await this.$api.requested(this.enterpriseParam)
  311. this.enterprise.enterpriseData = res.data
  312. this.enterprise.total = res.total
  313. this.enterprise.currentPage = res.pageNumber
  314. },
  315. enterpriseData(row){
  316. console.log(row,'row')
  317. this.form.sys_enterpriseid = row.sys_enterpriseid
  318. this.form.enterprisename = row.enterprisename
  319. this.enterpriseShow = false
  320. },
  321. handleSizeChange(val) {
  322. // console.log(`每页 ${val} 条`);
  323. this.enterpriseParam.content.pageSize = val
  324. this.queryEnterprise()
  325. },
  326. handleCurrentChange(val) {
  327. // console.log(`当前页: ${val}`);
  328. this.enterpriseParam.content.pageNumber = val
  329. this.queryEnterprise()
  330. },
  331. /*获取返利代金券*/
  332. async queryCashCoupon(){
  333. this.cashCouponParam.content.where.condition = this.form.enterprisename
  334. const res = await this.$api.requested(this.cashCouponParam)
  335. this.cashCoupon.cashCouponData = res.data
  336. this.cashCoupon.total = res.total
  337. this.cashCoupon.currentPage = res.pageNumber
  338. },
  339. cashCouponData(row){
  340. console.log(row)
  341. this.form.sa_cashbillid_billno = row.billno
  342. this.form.sa_cashbillid_rebate = row.sa_cashbillid
  343. this.cashCouponAmount = row.amount
  344. this.cashCouponShow = false
  345. },
  346. handleSizeChangeCashCoupon(val) {
  347. // console.log(`每页 ${val} 条`);
  348. this.enterpriseParam.content.pageSize = val
  349. this.queryCashCoupon()
  350. },
  351. handleCurrentChangeCashCoupon(val) {
  352. // console.log(`当前页: ${val}`);
  353. this.enterpriseParam.content.pageNumber = val
  354. this.queryCashCoupon()
  355. },
  356. onClose(){
  357. this.$refs.form.resetFields()
  358. this.form = {
  359. "sa_cashbillid": 0,
  360. "sys_enterpriseid": '', //合作企业档案ID
  361. "remarks": "",
  362. "subclass": "", //明细分类
  363. "amount": '', //金额
  364. "billdate": "", //单据日期
  365. "enterprisename":"",
  366. "sa_cashbillid_rebate": '', //所选的代金券id
  367. "sa_cashbillid_billno":""
  368. }
  369. }
  370. }
  371. }
  372. </script>
  373. <style scoped>
  374. </style>