sporadicList.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 零星收费
  6. </h2>
  7. <div class="m-core">
  8. <!-- v-permission="'sporadicChargeInfo/add'" -->
  9. <div class="newBand"
  10. v-permission="'sporadicChargeInfo/add'"
  11. @click="newVisible">新增公用收费</div>
  12. <div class="newBand"
  13. v-permission="'sporadicChargeInfo/add'"
  14. @click="newVisible1">新增个人收费</div>
  15. <el-form :inline="true"
  16. :model="searchForm">
  17. <el-form-item>
  18. <el-input placeholder="标题或学生姓名"
  19. v-model.trim="searchForm.search"></el-input>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-select v-model.trim="searchForm.organId"
  23. placeholder='请选择分部'
  24. clearable
  25. filterable>
  26. <el-option v-for='(item,index) in organList'
  27. :key="index"
  28. :value="item.id"
  29. :label="item.name"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-select v-model.trim="searchForm.chargeType"
  34. placeholder='请选择收费类型'
  35. clearable>
  36. <el-option v-for="item in orderType"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value"></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-select v-model.trim="searchForm.openFlag"
  44. placeholder='收费状态'
  45. clearable>
  46. <el-option label="关闭"
  47. value="1"></el-option>
  48. <el-option label="开启"
  49. value="0"></el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-select v-model.trim="searchForm.type"
  54. placeholder='请选择订单类型'
  55. clearable>
  56. <el-option label="个人"
  57. value="personal"></el-option>
  58. <el-option label="公用"
  59. value="common"></el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item>
  63. <el-button type="danger"
  64. @click="search">搜索</el-button>
  65. <el-button @click="onReSet"
  66. type="primary">重置</el-button>
  67. <el-button @click="exportSporad"
  68. v-permission="'export/sporadicChargeInfo'"
  69. style=" background: #14928a; border:1px solid #14928a;color:#fff">导出</el-button>
  70. </el-form-item>
  71. </el-form>
  72. <div class="tableWrap">
  73. <el-table :data='tableList'
  74. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  75. <el-table-column align='center'
  76. label="分部"
  77. prop="organName">
  78. </el-table-column>
  79. <el-table-column align='center'
  80. label="收费类型">
  81. <template slot-scope="scope">
  82. <div>
  83. {{ scope.row.chargeType | chargeTypeFilter }}
  84. </div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column align='center'
  88. label="标题"
  89. prop="title">
  90. </el-table-column>
  91. <el-table-column align='center'
  92. label="收费状态">
  93. <template slot-scope="scope">
  94. <div>
  95. {{ scope.row.openFlag?'关闭':'开启'}}
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column align='center'
  100. label="金额"
  101. prop="amount">
  102. <template slot-scope="scope">
  103. <div>
  104. {{scope.row.amount | moneyFormat}}
  105. </div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column align='center'
  109. label="时间">
  110. <template slot-scope="scope">
  111. <div>
  112. {{ scope.row.createTime | formatTimer }}
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column align='center'
  117. label="学生姓名"
  118. prop="userName">
  119. <template slot-scope="scope">
  120. {{ scope.row.userName || '-' }}
  121. </template>
  122. </el-table-column>
  123. <el-table-column align='center'
  124. label="订单类型">
  125. <template slot-scope="scope">
  126. {{ scope.row.userId ? '个人' : '公用' }}
  127. </template>
  128. </el-table-column>
  129. <el-table-column align='center'
  130. label="创建人"
  131. prop="operatorName">
  132. </el-table-column>
  133. <el-table-column align='center'
  134. label="操作">
  135. <template slot-scope="scope">
  136. <div>
  137. <el-button type="text" v-if="scope.row.chargeType == 12" key="update"
  138. v-permission="'sporadicChargeInfo/update'"
  139. @click="lookVisible(scope.row)">修改</el-button>
  140. <el-button type="text" v-else key="update"
  141. v-permission="'sporadicChargeInfo/look'"
  142. @click="lookVisible(scope.row)">查看</el-button>
  143. <el-button type="text"
  144. v-permission="'sporadicChargeInfo/delete'"
  145. @click="removeItem(scope.row)">删除</el-button>
  146. <el-button type="text"
  147. v-if="scope.row.openFlag"
  148. v-permission="'sporadicChargeInfo/updateOpenFlag'"
  149. @click="setSporadic(scope.row)">开启</el-button>
  150. <el-button type="text"
  151. v-else
  152. v-permission="'sporadicChargeInfo/updateOpenFlag'"
  153. @click="setSporadic(scope.row)">关闭</el-button>
  154. </div>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination :total="pageInfo.total"
  159. :page.sync="pageInfo.page"
  160. :limit.sync="pageInfo.limit"
  161. :page-sizes="pageInfo.page_size"
  162. @pagination="getList" />
  163. </div>
  164. </div>
  165. <el-dialog :title="title"
  166. :visible.sync="zeroVisible"
  167. @close="onFormClose('maskForm')"
  168. width="650px">
  169. <el-form :model='maskForm'
  170. :rules="maskRules"
  171. label-width="110px"
  172. label-position="right"
  173. :inline="true"
  174. ref="maskForm">
  175. <el-form-item label="标题"
  176. prop="title">
  177. <el-input v-model.trim="maskForm.title"
  178. :disabled='!isNew'></el-input>
  179. </el-form-item>
  180. <el-form-item label="收费类型"
  181. prop="type">
  182. <el-select v-model.trim="maskForm.type"
  183. :disabled='!isNew'
  184. clearable
  185. filterable>
  186. <el-option v-for="item in orderType1"
  187. :key="item.value"
  188. :label="item.label"
  189. :value="item.value"></el-option>
  190. </el-select>
  191. </el-form-item>
  192. <el-form-item label="金额"
  193. prop='money'>
  194. <el-input v-model.trim="maskForm.money"
  195. type="number"
  196. @mousewheel.native.prevent
  197. :disabled='!isNew'></el-input>
  198. </el-form-item>
  199. <el-form-item label="是否开启限制"
  200. prop="openMaxTerm"
  201. :rules="[{ required: true, message: '请选择是否开启目标金额', trigger: 'change' }]"
  202. v-if="maskForm.type == 12">
  203. <el-select v-model.trim="maskForm.openMaxTerm" clearable>
  204. <el-option :value="1" label="是"></el-option>
  205. <el-option :value="0" label="否"></el-option>
  206. </el-select>
  207. </el-form-item>
  208. <el-form-item label="目标金额"
  209. prop="maxAmount"
  210. :rules="[{ required: true, validator: validMaxNum, trigger: 'blur' }]"
  211. v-if="maskForm.type == 12">
  212. <el-input v-model.trim="maskForm.maxAmount"
  213. type="number"
  214. @mousewheel.native.prevent></el-input>
  215. </el-form-item>
  216. <el-form-item label="减免金额"
  217. v-if="maskForm.type == 6"
  218. prop='money'>
  219. <el-input v-model.trim="maskForm.subMoney"
  220. type="number"
  221. @mousewheel.native.prevent
  222. :disabled='!isNew'></el-input>
  223. </el-form-item>
  224. <el-form-item label="分部"
  225. prop="organId">
  226. <el-select v-model.trim="maskForm.organId"
  227. :disabled='!isNew'
  228. clearable
  229. @change="onMusicGroupChange"
  230. filterable>
  231. <el-option v-for='(item,index) in organList'
  232. :key="index"
  233. :value="item.id"
  234. :label="item.name"></el-option>
  235. </el-select>
  236. </el-form-item>
  237. <el-form-item label="所属乐团"
  238. v-if="maskForm.type != 12"
  239. prop="musicGroupId">
  240. <el-select v-model.trim="maskForm.musicGroupId"
  241. :disabled='!isNew || !maskForm.organId'
  242. clearable
  243. filterable>
  244. <el-option v-for='item in maskMusicList'
  245. :key="item.musicGroupId"
  246. :value="item.musicGroupId"
  247. :label="item.musicGroupName"></el-option>
  248. </el-select>
  249. </el-form-item>
  250. <el-form-item label="查看链接"
  251. v-if="!isNew">
  252. <el-input style='width:400px !important'
  253. :disabled='!isNew'
  254. v-model.trim="maskForm.code"></el-input>
  255. <el-button type='danger'
  256. @click="qrcodeStatus = true">二维码</el-button>
  257. </el-form-item>
  258. <el-form-item label="收费详情"
  259. prop="desc">
  260. <el-input type='textarea'
  261. :disabled='!isNew'
  262. v-model.trim="maskForm.desc"
  263. style="width:490px"
  264. :autosize="{minRows: 5}"></el-input>
  265. </el-form-item>
  266. </el-form>
  267. <span slot="footer"
  268. class="dialog-footer">
  269. <el-button @click="zeroVisible = false">取 消</el-button>
  270. <el-button type="primary"
  271. v-if="isNew"
  272. @click="addZero">确 定</el-button>
  273. <el-button v-if="!isNew"
  274. type="primary"
  275. @click="updateZero">确定</el-button>
  276. </span>
  277. </el-dialog>
  278. <el-dialog :title="title1"
  279. :visible.sync="zeroVisible1"
  280. @close="onFormClose('maskForm1')"
  281. width="650px">
  282. <el-form :model='maskForm1'
  283. :rules="maskRules1"
  284. label-width="100px"
  285. label-position="right"
  286. :inline="true"
  287. ref="maskForm1">
  288. <el-form-item label="标题"
  289. prop="title">
  290. <el-input v-model.trim="maskForm1.title"
  291. :disabled='!isNew1'></el-input>
  292. </el-form-item>
  293. <el-form-item label="收费类型"
  294. prop="type">
  295. <el-select v-model.trim="maskForm1.type"
  296. :disabled='!isNew1'
  297. clearable
  298. filterable>
  299. <template v-for="item in orderType1">
  300. <el-option v-if="item.value != 12"
  301. :key="item.value"
  302. :label="item.label"
  303. :value="item.value"></el-option>
  304. </template>
  305. </el-select>
  306. </el-form-item>
  307. <el-form-item label="学员编号"
  308. prop='studentId'>
  309. <el-input v-model.trim="maskForm1.studentId"
  310. @blur="onStudentChange"
  311. type="number"
  312. maxlength="10"
  313. @mousewheel.native.prevent
  314. :disabled='!isNew1'></el-input>
  315. </el-form-item>
  316. <el-form-item label="金额"
  317. prop='money'>
  318. <el-input v-model.trim="maskForm1.money"
  319. type="number"
  320. @mousewheel.native.prevent
  321. :disabled='!isNew1'></el-input>
  322. </el-form-item>
  323. <el-form-item label="学员姓名"
  324. prop='studentName'>
  325. <el-input v-model.trim="maskForm1.studentName"
  326. :disabled='true'></el-input>
  327. </el-form-item>
  328. <el-form-item label="所属乐团"
  329. prop="musicGroupId">
  330. <el-select v-model.trim="maskForm1.musicGroupId"
  331. :disabled='!isNew1'
  332. clearable
  333. filterable>
  334. <el-option v-for='(item,index) in maskMusicList1'
  335. :key="index"
  336. :value="item.musicGroupId"
  337. :label="item.musicGroupName"></el-option>
  338. </el-select>
  339. </el-form-item>
  340. <el-form-item label="查看链接"
  341. v-if="!isNew1">
  342. <el-input style='width:400px !important'
  343. :disabled='!isNew1'
  344. v-model.trim="maskForm1.code"></el-input>
  345. <el-button type='danger'
  346. @click="qrcodeStatus = true">二维码</el-button>
  347. </el-form-item>
  348. <el-form-item label="收费详情"
  349. prop="desc">
  350. <el-input type='textarea'
  351. :disabled='!isNew1'
  352. v-model.trim="maskForm1.desc"
  353. style="width:490px"
  354. :autosize="{minRows: 5}"></el-input>
  355. </el-form-item>
  356. </el-form>
  357. <span slot="footer"
  358. class="dialog-footer">
  359. <el-button @click="zeroVisible1 = false">取 消</el-button>
  360. <el-button type="primary"
  361. v-if="isNew1"
  362. @click="addZero1">确 定</el-button>
  363. <el-button v-if="!isNew1"
  364. type="primary"
  365. @click="zeroVisible1 = false">确定</el-button>
  366. </span>
  367. </el-dialog>
  368. <el-dialog :visible.sync="qrcodeStatus"
  369. center
  370. width="300px">
  371. <div class="right-code">
  372. <h2 class="title">缴费链接</h2>
  373. <vue-qr :text="qrCodeUrl"
  374. style="width: 100%"
  375. :margin="0"></vue-qr>
  376. <!-- <div id="qrcode"
  377. class="qrcode code"
  378. ref="qrCodeUrl"></div> -->
  379. <!-- <p class="code-url"
  380. v-if="codeUrl2">{{ codeUrl2 }}</p> -->
  381. </div>
  382. </el-dialog>
  383. </div>
  384. </template>
  385. <script>
  386. import { getEmployeeOrgan } from '@/api/buildTeam'
  387. import pagination from '@/components/Pagination/index'
  388. import { vaildStudentUrl } from '@/utils/validate'
  389. import cleanDeep from 'clean-deep'
  390. import { addZero, getZero, updateZero, removeZero, getBasic, updateOpenFlag, queryOrganMusicInfos, queryUserMusicInfos } from '@/api/zeroManager'
  391. import axios from 'axios'
  392. import qs from 'qs'
  393. import {
  394. getToken
  395. } from '@/utils/auth'
  396. import load from '@/utils/loading'
  397. // import QRCode from 'qrcodejs2'
  398. import vueQr from 'vue-qr'
  399. let validMaxNum = (rule, value, callback) => {
  400. if (value == '' && typeof value == 'string' || value == null) {
  401. callback(new Error('请输入缴费金额'))
  402. } else if (value < 0) {
  403. callback(new Error('输入缴费金额必须大于0'))
  404. } else {
  405. callback()
  406. }
  407. }
  408. export default {
  409. name: 'sporadicList',
  410. components: { pagination, vueQr },
  411. data () {
  412. return {
  413. validMaxNum: validMaxNum,
  414. zeroVisible: false,
  415. qrCodeUrl: null,
  416. searchForm: {
  417. organId: null,
  418. chargeType: null,
  419. type: null,
  420. search: null,
  421. openFlag: null
  422. },
  423. tableList: [],
  424. organList: [],
  425. orderType: [
  426. { label: '考级', value: 1 },
  427. { label: '声部更改', value: 2 },
  428. { label: '乐器更换', value: 3 },
  429. { label: '配件销售', value: 4 },
  430. { label: '维修费', value: 5 },
  431. { label: '福袋活动', value: 6 },
  432. { label: '双十一活动', value: 12 },
  433. { label: '上门费', value: 7 },
  434. { label: '账户充值', value: 9 },
  435. { label: '乐保服务', value: 10 },
  436. { label: '其它', value: 11 }
  437. ],
  438. orderType1: [
  439. { label: '考级', value: 1 },
  440. { label: '声部更改', value: 2 },
  441. // { label: '乐器更换', value: 3 },
  442. // { label: '配件销售', value: 4 },
  443. // { label: '双十一活动', value: 12 },
  444. { label: '上门费', value: 7 },
  445. { label: '账户充值', value: 9 },
  446. { label: '乐保服务', value: 10 },
  447. ],
  448. maskForm: {
  449. organId: '',
  450. type: '',
  451. money: '',
  452. desc: '',
  453. title: '',
  454. code: '',
  455. musicGroupId: '',
  456. maxAmount: null,
  457. openMaxTerm: null,
  458. subMoney: ''
  459. },
  460. maskMusicList: [],
  461. maskRules: {
  462. organId: [{ required: true, message: '请选择分部', trigger: 'change' }],
  463. // musicGroupId: [{ required: true, message: '请选择所属乐团', trigger: 'change' }],
  464. type: [{ required: true, message: '请选择收费类型', trigger: 'change' }],
  465. money: [{ required: true, message: '请输入收费金额', trigger: 'change' }],
  466. title: [{ required: true, message: '请输入标题名称', trigger: 'change' }],
  467. desc: [{ required: true, message: '请输入收费详情' }]
  468. },
  469. pageInfo: {
  470. // 分页规则
  471. limit: 10, // 限制显示条数
  472. page: 1, // 当前页
  473. total: 0, // 总条数
  474. page_size: [10, 20, 40, 50] // 选择限制显示条数
  475. },
  476. isNew: false,
  477. title: '新增收费',
  478. qrcodeStatus: false,
  479. qrcodes: true,
  480. activeRow: null,
  481. title1: '新增收费',
  482. activeRow1: null,
  483. zeroVisible1: false,
  484. maskForm1: {
  485. type: null,
  486. money: null,
  487. desc: null,
  488. title: null,
  489. code: null,
  490. musicGroupId: null,
  491. studentId: null,
  492. studentName: null,
  493. },
  494. isNew1: false,
  495. maskMusicList1: [],
  496. maskRules1: {
  497. organId: [{ required: true, message: '请选择分部', trigger: 'change' }],
  498. // musicGroupId: [{ required: true, message: '请选择所属乐团', trigger: 'change' }],
  499. type: [{ required: true, message: '请选择收费类型', trigger: 'change' }],
  500. money: [{ required: true, message: '请输入收费金额', trigger: 'change' }],
  501. title: [{ required: true, message: '请输入标题名称', trigger: 'change' }],
  502. studentId: [{ required: true, message: '请输入学员编号', trigger: 'blur' }],
  503. desc: [{ required: true, message: '请输入收费详情' }]
  504. },
  505. }
  506. }, mounted () {
  507. getEmployeeOrgan().then(res => {
  508. if (res.code == 200) {
  509. this.organList = res.data;
  510. }
  511. })
  512. this.getList();
  513. },
  514. methods: {
  515. search () {
  516. this.pageInfo.page = 1;
  517. this.getList()
  518. },
  519. onReSet () {
  520. this.searchForm = {
  521. organId: null,
  522. chargeType: null,
  523. type: null,
  524. search: null
  525. }
  526. },
  527. getList () {
  528. let searchForm = this.searchForm
  529. let params = {
  530. organId: searchForm.organId ? searchForm.organId : null,
  531. chargeType: searchForm.chargeType ? searchForm.chargeType : null,
  532. type: searchForm.type ? searchForm.type : null,
  533. search: searchForm.search ? searchForm.search : null,
  534. openFlag: searchForm.openFlag ? searchForm.openFlag * 1 : null,
  535. page: this.pageInfo.page,
  536. rows: this.pageInfo.limit
  537. }
  538. getZero(params).then(res => {
  539. if (res.code == 200) {
  540. this.tableList = res.data.rows
  541. this.pageInfo.total = res.data.total
  542. }
  543. })
  544. },
  545. onFormClose (formName) { // 关闭弹窗重置验证
  546. if (formName == 'maskForm') {
  547. this.maskForm = {
  548. organId: null,
  549. musicGroupId: null,
  550. type: null,
  551. money: null,
  552. maxAmount: null,
  553. openMaxTerm: null,
  554. desc: null,
  555. title: null,
  556. code: null
  557. }
  558. } else if (formName == 'maskForm1') {
  559. this.maskForm1 = {
  560. type: null,
  561. musicGroupId: null,
  562. money: null,
  563. desc: null,
  564. title: null,
  565. code: null,
  566. studentId: null,
  567. studentName: null,
  568. }
  569. }
  570. if (this.$refs[formName]) {
  571. this.$refs[formName].resetFields()
  572. }
  573. },
  574. newVisible () {
  575. this.isNew = true;
  576. this.zeroVisible = true;
  577. this.title = '新增公用收费'
  578. },
  579. newVisible1 () {
  580. this.isNew1 = true;
  581. this.zeroVisible1 = true;
  582. this.title1 = '新增个人收费'
  583. },
  584. lookVisible (row) {
  585. let maskForm = null
  586. if (row.userId) {
  587. maskForm = this.maskForm1
  588. this.isNew1 = false;
  589. this.zeroVisible1 = true;
  590. this.title1 = '查看个人收费'
  591. let url = vaildStudentUrl() + `/#/sporadicPay?id=${row.id}&userId=${row.userId}`
  592. this.qrCodeUrl = url
  593. maskForm.code = url
  594. maskForm.studentId = row.userId
  595. maskForm.studentName = row.userName
  596. } else {
  597. maskForm = this.maskForm
  598. this.isNew = false;
  599. this.zeroVisible = true;
  600. this.title = '查看公用收费'
  601. let url = vaildStudentUrl() + `/#/sporadicLogin?id=${row.id}`
  602. this.qrCodeUrl = url
  603. maskForm.code = url
  604. }
  605. maskForm.type = parseInt(row.chargeType)
  606. maskForm.id = row.id
  607. maskForm.desc = row.detail
  608. maskForm.title = row.title
  609. maskForm.organId = row.organId
  610. maskForm.money = row.amount
  611. maskForm.subMoney = row.discountAmount
  612. maskForm.maxAmount = row.maxAmount
  613. maskForm.openMaxTerm = row.openMaxTerm
  614. maskForm.musicGroupId = row.musicGroupId ? row.musicGroupId : null
  615. if (row.userId) {
  616. queryUserMusicInfos({ userId: row.userId }).then(studentInfo => {
  617. if (studentInfo.code == 200) {
  618. this.maskMusicList1 = studentInfo.data
  619. }
  620. })
  621. } else {
  622. this.onMusicGroupChange(true)
  623. }
  624. },
  625. onMusicGroupChange (status) {
  626. let maskForm = this.maskForm
  627. if (!maskForm.organId) {
  628. return
  629. }
  630. if (!status) {
  631. maskForm.musicGroupId = null // 重置可能已经选中的乐团
  632. }
  633. queryOrganMusicInfos({ organId: maskForm.organId }).then(res => {
  634. if (res.code == 200) {
  635. this.maskMusicList = res.data
  636. }
  637. })
  638. },
  639. updateZero() {
  640. let maskForm = this.maskForm
  641. if(maskForm.type != 12) {
  642. this.zeroVisible = false
  643. return
  644. }
  645. this.$refs['maskForm'].validate(item => {
  646. if(item) {
  647. updateZero(cleanDeep({ id: maskForm.id, maxAmount: maskForm.maxAmount, openMaxTerm: maskForm.openMaxTerm })).then(res => {
  648. if (res.code == 200) {
  649. this.$message.success('更新成功')
  650. this.zeroVisible = false;
  651. this.getList()
  652. }
  653. })
  654. }
  655. })
  656. },
  657. addZero () {
  658. this.$refs['maskForm'].validate(item => {
  659. if (item) {
  660. let maskForm = this.maskForm
  661. let obj = {
  662. chargeType: maskForm.type,
  663. detail: maskForm.desc,
  664. title: maskForm.title,
  665. organId: maskForm.organId,
  666. amount: maskForm.money,
  667. musicGroupId: maskForm.musicGroupId,
  668. discountAmount: maskForm.subMoney,
  669. }
  670. if(maskForm.type == 12) {
  671. obj.maxAmount = maskForm.maxAmount,
  672. obj.openMaxTerm = maskForm.openMaxTerm
  673. }
  674. addZero(obj).then(res => {
  675. if (res.code == 200) {
  676. this.$message.success('新增成功')
  677. this.zeroVisible = false;
  678. this.getList()
  679. }
  680. })
  681. }
  682. })
  683. },
  684. addZero1 () {
  685. this.$refs['maskForm1'].validate(item => {
  686. if (item) {
  687. let maskForm1 = this.maskForm1
  688. if (!maskForm1.studentName) {
  689. this.$message.error('学员信息不存在')
  690. return
  691. }
  692. let obj = {
  693. chargeType: maskForm1.type,
  694. detail: maskForm1.desc,
  695. title: maskForm1.title,
  696. musicGroupId: this.maskForm1.musicGroupId,
  697. userId: maskForm1.studentId,
  698. amount: maskForm1.money
  699. }
  700. addZero(obj).then(res => {
  701. if (res.code == 200) {
  702. this.$message.success('新增成功')
  703. this.zeroVisible1 = false;
  704. this.getList()
  705. }
  706. })
  707. }
  708. })
  709. },
  710. async onStudentChange () {
  711. let studentId = this.maskForm1.studentId
  712. // 判断学生编号是否存在
  713. if (!studentId) {
  714. return
  715. }
  716. if (studentId.length > 10) {
  717. this.$message.error('学员编号不合法')
  718. return
  719. }
  720. await getBasic({ userId: studentId }).then(res => {
  721. if (res.code == 200) {
  722. if (res.data) {
  723. this.maskForm1.studentName = res.data.name
  724. queryUserMusicInfos({ userId: studentId }).then(studentInfo => {
  725. if (studentInfo.code == 200) {
  726. this.maskMusicList1 = studentInfo.data
  727. }
  728. })
  729. } else {
  730. this.maskForm1.studentName = null
  731. }
  732. }
  733. })
  734. },
  735. removeItem (row) {
  736. this.$confirm('是否删除该收费', '提示', {
  737. confirmButtonText: '确定',
  738. cancelButtonText: '取消',
  739. type: 'warning'
  740. }).then(() => {
  741. removeZero({ id: row.id }).then(res => {
  742. if (res.code == 200) {
  743. this.$message.success('删除成功')
  744. this.zeroVisible = false;
  745. this.getList()
  746. }
  747. })
  748. }).catch(() => {
  749. });
  750. },
  751. setSporadic (row) {
  752. // openFlag
  753. let str = ''
  754. let openFlag = ''
  755. if (row.openFlag) {
  756. // 关闭=>开启 1是关闭
  757. openFlag = 0;
  758. str = '开启'
  759. } else {
  760. // 开启=>关闭 0是开启
  761. openFlag = 1;
  762. str = '关闭'
  763. }
  764. this.$confirm(`是否${str}该收费`, '提示', {
  765. confirmButtonText: '确定',
  766. cancelButtonText: '取消',
  767. type: 'warning'
  768. }).then(() => {
  769. updateOpenFlag({ sporadicId: row.id, openFlag }).then(res => {
  770. if (res.code == 200) {
  771. this.$message.success(`${str}成功`)
  772. this.getList()
  773. }
  774. })
  775. }).catch(() => {
  776. });
  777. },
  778. exportSporad () {
  779. let url = '/api-web/export/sporadicChargeInfo'
  780. let data = this.searchForm
  781. const options = {
  782. method: 'get',
  783. headers: {
  784. 'Authorization': getToken()
  785. },
  786. params: data,
  787. url,
  788. responseType: 'blob'
  789. }
  790. this.$confirm('您确定导出零星缴费列表', '提示', {
  791. confirmButtonText: '确定',
  792. cancelButtonText: '取消',
  793. type: 'warning'
  794. }).then(() => {
  795. load.startLoading()
  796. axios(options).then(res => {
  797. let blob = new Blob([res.data], {
  798. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  799. type: 'application/vnd.ms-excel;charset=utf-8'
  800. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  801. })
  802. let text = (new Response(blob)).text()
  803. text.then(res => {
  804. // 判断是否报错
  805. if (res.indexOf('code') != -1) {
  806. let json = JSON.parse(res)
  807. this.$message.error(json.msg)
  808. } else {
  809. let objectUrl = URL.createObjectURL(blob)
  810. let link = document.createElement("a")
  811. let nowTime = new Date()
  812. let ymd = nowTime.getFullYear() + '' + (nowTime.getMonth() + 1) + '' + nowTime.getDate()
  813. let fname = ymd + '零星缴费' //下载文件的名字
  814. link.href = objectUrl
  815. link.setAttribute("download", fname)
  816. document.body.appendChild(link)
  817. link.click()
  818. }
  819. })
  820. load.endLoading();
  821. }).catch(error => {
  822. this.$message.error('导出数据失败,请联系管理员');
  823. load.endLoading();
  824. })
  825. }).catch(() => { })
  826. }
  827. },
  828. watch: {
  829. zeroVisible (val) {
  830. if (!val) {
  831. this.maskForm = {
  832. organId: '',
  833. type: '',
  834. money: '',
  835. desc: '',
  836. title: '',
  837. maxAmount: null,
  838. openMaxTerm: null,
  839. code: ''
  840. }
  841. // this.$refs['maskForm'].resetFields()
  842. // console.log(this.$refs['zeroForm'].resetFields)
  843. }
  844. },
  845. },
  846. filters: {
  847. chargeTypeFilter (val) {
  848. let template = {
  849. '1': '考级',
  850. '2': '声部更改',
  851. '3': '乐器更换',
  852. '4': '配件销售',
  853. '5': '维修费',
  854. '6': '福袋活动',
  855. '7': '上门费',
  856. '9': '账户充值',
  857. '10': '乐保服务',
  858. '11': '其它',
  859. '12': '双十一活动'
  860. }
  861. return template[val]
  862. }
  863. }
  864. }
  865. </script>
  866. <style lang="scss" scoped>
  867. .right-code {
  868. // width: 50%;
  869. // float: left;
  870. .title {
  871. font-size: 18px;
  872. text-align: center;
  873. padding-bottom: 8px;
  874. }
  875. }
  876. .newBand {
  877. display: inline-block;
  878. }
  879. .el-input {
  880. width: 180px !important;
  881. }
  882. </style>