index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 乐器置换
  7. </h2>
  8. <div class="m-core">
  9. <div class="btnList">
  10. <!-- v-permission="'export/practiceGroup'" -->
  11. <div
  12. class="newBand"
  13. @click="makeUrl"
  14. style="max-width: 150px; margin-right: 10px"
  15. v-if="permission('replacementInstrumentCooperation/add')"
  16. >
  17. 生成链接
  18. </div>
  19. <div class="newBand" @click="onExport" style="max-width: 150px" v-if="permission('replacementInstrumentActivity/export')">
  20. 导出
  21. </div>
  22. </div>
  23. <save-form
  24. :inline="true"
  25. ref="searchForm"
  26. :model="searchForm"
  27. @submit="search"
  28. @reset="onReSet"
  29. >
  30. <el-form-item prop="search">
  31. <el-input
  32. v-model.trim="searchForm.search"
  33. clearable
  34. @keyup.enter.native="search"
  35. placeholder="学校名称或编号"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item prop="organId">
  39. <el-select
  40. v-model.trim="searchForm.organId"
  41. filterable
  42. clearable
  43. placeholder="请选择分部"
  44. >
  45. <el-option
  46. v-for="(item, index) in selects.branchs"
  47. :key="index"
  48. :label="item.name"
  49. :value="item.id"
  50. ></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item prop="openPay">
  54. <el-select
  55. class="multiple"
  56. v-model.trim="searchForm.openPay"
  57. filterable
  58. clearable
  59. placeholder="是否开启缴费"
  60. >
  61. <el-option label="是" value="YES"></el-option>
  62. <el-option label="否" value="NO"></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item>
  66. <el-button native-type="submit" type="primary">搜索</el-button>
  67. <el-button native-type="reset" type="danger">重置</el-button>
  68. </el-form-item>
  69. </save-form>
  70. <div class="tableWrap">
  71. <el-table
  72. style="width: 100%"
  73. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  74. :data="tableList"
  75. >
  76. <el-table-column
  77. align="center"
  78. prop="id"
  79. label="编号"
  80. ></el-table-column>
  81. <el-table-column
  82. align="center"
  83. prop="organName"
  84. label="分部"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. prop="cooperationOrganName"
  89. label="合作单位"
  90. >
  91. <template slot-scope="scope">
  92. <div>
  93. {{ scope.row.cooperationOrganName }}
  94. <!-- (<copy-text> {{ scope.row.cooperationOrganId }} </copy-text>) -->
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" label="问卷名称" prop="topicTitle"></el-table-column>
  99. <!-- <el-table-column
  100. align="center"
  101. prop="showQuestion"
  102. label="是否参加问卷调查"
  103. >
  104. <template slot-scope="scope">
  105. {{ scope.row.showQuestion ? '是' : '否' }}
  106. </template>
  107. </el-table-column> -->
  108. <el-table-column
  109. align="center"
  110. prop="activeNum"
  111. label="调查人数"
  112. ></el-table-column>
  113. <el-table-column
  114. align="center"
  115. prop="replaceNum"
  116. label="置换人数"
  117. ></el-table-column>
  118. <el-table-column align="center" prop="replaceScale" label="置换率">
  119. <template slot-scope="scope">
  120. <div>{{ scope.row.replaceScale }}%</div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" prop="replaceScale" label="缴费率">
  124. <template slot-scope="scope">
  125. <div>{{ scope.row.payScale }}%</div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column align="center" prop="openPay" label="是否开启缴费">
  129. <template slot-scope="scope">
  130. <div>{{ scope.row.openPay ? "是" : "否" }}</div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" width="250px" label="操作">
  134. <template slot-scope="scope">
  135. <div>
  136. <el-button type="text" @click="lookDetail(scope.row)" v-if="permission('replacementInstrumentActivity/queryPage')">问卷详情</el-button>
  137. <el-button type="text" @click="lookDetail(scope.row, 'answer')" v-if="permission('/reaplceMusicPlayer/answer')">问答详情</el-button>
  138. <el-button
  139. type="text"
  140. @click="onCreateQRCode(scope.row, '调查链接')"
  141. >调查链接</el-button
  142. >
  143. <el-button
  144. type="text"
  145. @click="onCreateQRCode(scope.row, '统计链接')"
  146. >统计链接</el-button
  147. >
  148. <el-button
  149. type="text"
  150. @click="openPay(scope.row)"
  151. v-if="
  152. !scope.row.openPay &&
  153. permission('replacementInstrumentCooperation/openPay')
  154. "
  155. >开启缴费</el-button
  156. >
  157. <el-button
  158. type="text"
  159. @click="onCreateQRCode(scope.row, '缴费链接')"
  160. v-if="scope.row.openPay">缴费链接</el-button>
  161. </div>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <pagination
  166. sync
  167. :total.sync="rules.total"
  168. :page.sync="rules.page"
  169. :limit.sync="rules.limit"
  170. :page-sizes="rules.page_size"
  171. @pagination="getList"
  172. />
  173. </div>
  174. </div>
  175. <el-dialog
  176. title="生成链接"
  177. :visible.sync="makeUrlVisible"
  178. width="500px"
  179. v-if="makeUrlVisible"
  180. >
  181. <addUrl ref="addUrl" @close="close" @getList="getList" />
  182. <div slot="footer">
  183. <el-button @click="makeUrlVisible = false">取 消</el-button>
  184. <el-button type="primary" @click="addurl">生成链接</el-button>
  185. </div>
  186. </el-dialog>
  187. <el-dialog
  188. title="详情"
  189. :visible.sync="detailVisible"
  190. width="1200px"
  191. v-if="detailVisible"
  192. >
  193. <detail ref="detail" @close="close" :detail="activeRow" />
  194. <div slot="footer">
  195. <el-button type="primary" @click="detailVisible = false"
  196. >确定</el-button
  197. >
  198. </div>
  199. </el-dialog>
  200. <qr-code v-model="qrcodeStatus" :title="qrcodeName" :codeUrl="codeUrl" />
  201. <!-- <el-dialog :title="qrcodeName" :visible.sync="qrcodeStatus" width="300px">
  202. <div class="left-code">
  203. <div id="qrcode" class="qrcode code" ref="qrCodeUrl"></div>
  204. <p class="code-url" v-if="codeUrl">
  205. <copy-text>
  206. {{ codeUrl }}
  207. </copy-text>
  208. </p>
  209. </div>
  210. </el-dialog> -->
  211. </div>
  212. </template>
  213. <script>
  214. import { permission } from "@/utils/directivePage";
  215. import { vaildStudentUrl, vaildTeachingUrl } from "@/utils/validate";
  216. import pagination from "@/components/Pagination/index";
  217. import addUrl from "./modals/addUrl";
  218. import detail from "./modals/detail";
  219. import { getReplacementList, openPayReplacement } from "./api";
  220. import { Export } from '@/utils/downLoadFile'
  221. import cleanDeep from 'clean-deep'
  222. import qs from 'qs';
  223. import QrCode from "@/components/QrCode/index";
  224. import { encode } from 'js-base64';
  225. export default {
  226. components: { pagination, addUrl, detail, QrCode },
  227. data() {
  228. return {
  229. searchForm: {
  230. search: null,
  231. organId: "",
  232. openPay: "",
  233. },
  234. tableList: [],
  235. rules: {
  236. // 分页规则
  237. limit: 10, // 限制显示条数
  238. page: 1, // 当前页
  239. total: 0, // 总条数
  240. page_size: [10, 20, 40, 50], // 选择限制显示条数
  241. },
  242. makeUrlVisible: false,
  243. detailVisible: false,
  244. codeUrl: "",
  245. qrcodes: true,
  246. qrcodeStatus: false,
  247. qrcodeName: "调查链接",
  248. activeRow: null,
  249. };
  250. },
  251. //生命周期 - 创建完成(可以访问当前this实例)
  252. created() {},
  253. //生命周期 - 挂载完成(可以访问DOM元素)
  254. mounted() {
  255. // 获取分部
  256. this.init();
  257. },
  258. methods: {
  259. permission(str, parent) {
  260. return permission(str, parent);
  261. },
  262. init() {
  263. this.$store.dispatch("setBranchs");
  264. this.getList();
  265. },
  266. async getList() {
  267. try {
  268. const res = await getReplacementList({
  269. ...this.searchForm,
  270. page: this.rules.page,
  271. rows: this.rules.limit,
  272. });
  273. this.rules.total = res.data.total;
  274. this.tableList = res.data.rows;
  275. } catch (e) {
  276. console.log(e);
  277. }
  278. },
  279. search() {
  280. this.rules.page = 1;
  281. this.getList();
  282. },
  283. onReSet() {
  284. this.$refs.searchForm.resetFields();
  285. this.search();
  286. },
  287. makeUrl() {
  288. this.makeUrlVisible = true;
  289. },
  290. addurl() {
  291. this.$refs.addUrl.submit();
  292. },
  293. close() {
  294. this.makeUrlVisible = false;
  295. this.detailVisible = false;
  296. },
  297. async onExport() {
  298. const { search, ...rest } = this.searchForm;
  299. let obj = {
  300. ...rest,
  301. // activeType: 'REPLACEMENT',
  302. page: this.rules.page,
  303. rows: this.rules.limit,
  304. cooperationOrganIdOrName:search
  305. };
  306. await Export(
  307. this,
  308. {
  309. url: "/api-web/replacementInstrumentActivity/export",
  310. fileName: "乐器置换列表.xls",
  311. method: "post",
  312. params: qs.stringify(cleanDeep(obj)),
  313. },
  314. "您确定导出乐器置换列表"
  315. );
  316. },
  317. lookDetail(row, type) {
  318. if(type == 'answer') {
  319. this.$router.push({
  320. path: '/reaplceMusicPlayer/answer',
  321. query: {
  322. id: row.id,
  323. topicId: row.topicId
  324. }
  325. })
  326. } else {
  327. this.activeRow = row;
  328. this.detailVisible = true;
  329. }
  330. },
  331. onCreateQRCode(row, name) {
  332. // 生成链接
  333. this.qrcodeName = name;
  334. this.qrcodeStatus = true;
  335. let id = this.$route.query.id;
  336. if (this.qrcodes) {
  337. this.qrcodes = false;
  338. // setTimeout(() => {
  339. // document.getElementById("qrcode").innerHTML = "";
  340. // this.qrcode = new QRCode("qrcode", {
  341. // width: 260,
  342. // height: 260,
  343. // colorDark: "#000000",
  344. // colorLight: "#ffffff",
  345. // correctLevel: QRCode.CorrectLevel.H,
  346. // });
  347. let str;
  348. if (name == "调查链接") {
  349. let returnUrl = vaildStudentUrl() + `/#/questionnaire?` + encodeURIComponent(encode(`id=${row.id}`));
  350. // console.log(returnUrl)
  351. // let tempUrl =
  352. // vaildStudentUrl() +
  353. // `/#/transfer?returnUrl=${encodeURIComponent(returnUrl)}`;
  354. str = returnUrl;
  355. } else if (name == "统计链接") {
  356. str =
  357. vaildTeachingUrl() +
  358. `/#/questionStatistics?o=${row.organId}&c=${row.cooperationOrganId}&id=${row.id}`;
  359. } else if(name == '缴费链接') {
  360. str = vaildStudentUrl() + `/#/questionGoodsSale?` + encodeURIComponent(encode(`rid=${row.id}`));
  361. }
  362. // vaildTeachingUrl
  363. // this.qrcode.makeCode(
  364. // str +
  365. // `/#/questionnaireInfo?o=${row.organId}&c=${row.cooperationOrganId}`
  366. // );
  367. this.codeUrl = str;
  368. this.qrcodes = true;
  369. // }, 100);
  370. }
  371. },
  372. openPay(row) {
  373. this.$confirm("确定开启缴费?", "提示", {
  374. confirmButtonText: "确定",
  375. cancelButtonText: "取消",
  376. type: "warning",
  377. })
  378. .then(async () => {
  379. try {
  380. const res = await openPayReplacement({ id: row.id });
  381. this.$message.success("开启缴费成功");
  382. this.getList();
  383. } catch (e) {
  384. console.log(e);
  385. }
  386. })
  387. .catch(() => {});
  388. },
  389. },
  390. };
  391. </script>
  392. <style lang='scss' scoped>
  393. .btnList {
  394. display: flex;
  395. flex-direction: row;
  396. justify-content: flex-start;
  397. }
  398. .code-url {
  399. margin-top: 10px;
  400. }
  401. </style>