index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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('create')"
  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="title"
  84. label="活动主题"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. prop="organName"
  89. label="分部"
  90. ></el-table-column>
  91. <el-table-column
  92. align="center"
  93. prop="cooperationOrganName"
  94. label="合作单位"
  95. >
  96. <template slot-scope="scope">
  97. <div>
  98. {{ scope.row.cooperationOrganName }}
  99. <!-- (<copy-text> {{ scope.row.cooperationOrganId }} </copy-text>) -->
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" label="问卷名称">
  104. <template slot-scope="scope">
  105. <span v-if="scope.row.topicTitle">{{ scope.row.topicTitle }}</span>
  106. <el-tag style="margin: 8px 20px; font-size: 14px;" type="danger" v-else>无问卷</el-tag>
  107. </template>
  108. </el-table-column>
  109. <!-- <el-table-column
  110. align="center"
  111. prop="showQuestion"
  112. label="是否参加问卷调查"
  113. >
  114. <template slot-scope="scope">
  115. {{ scope.row.showQuestion ? '是' : '否' }}
  116. </template>
  117. </el-table-column> -->
  118. <el-table-column
  119. align="center"
  120. prop="activeNum"
  121. label="调查人数"
  122. ></el-table-column>
  123. <el-table-column
  124. align="center"
  125. prop="replaceNum"
  126. label="置换人数"
  127. ></el-table-column>
  128. <el-table-column align="center" prop="replaceScale" label="置换率">
  129. <template slot-scope="scope">
  130. <div>{{ scope.row.replaceScale }}%</div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" prop="replaceScale" label="缴费率">
  134. <template slot-scope="scope">
  135. <div>{{ scope.row.payScale }}%</div>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" prop="openPay" label="是否开启缴费">
  139. <template slot-scope="scope">
  140. <div>{{ scope.row.openPay ? "是" : "否" }}</div>
  141. </template>
  142. </el-table-column>
  143. <el-table-column align="center" width="250px" label="操作">
  144. <template slot-scope="scope">
  145. <div>
  146. <el-button type="text" @click="lookDetail(scope.row)" v-if="permission('replacementInstrumentActivity/queryPage')">问卷详情</el-button>
  147. <el-button type="text" @click="lookDetail(scope.row, 'answer')" v-if="permission('/reaplceMusicPlayer/answer')">问答详情</el-button>
  148. <el-button type="text" @click="makeUrl('update', scope.row)" v-if="permission('replacementInstrumentCooperation/update')">修改主题</el-button>
  149. <el-button
  150. type="text"
  151. @click="openPay(scope.row)"
  152. v-if="
  153. !scope.row.openPay &&
  154. permission('replacementInstrumentCooperation/openPay')
  155. "
  156. >开启缴费</el-button>
  157. <el-dropdown>
  158. <span class="el-dropdown-link" style="color: #14928A">
  159. 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
  160. </span>
  161. <el-dropdown-menu slot="dropdown" style="margin-left: 10px;">
  162. <el-dropdown-item>
  163. <el-button type="text" @click="onCreateQRCode(scope.row, '调查链接')" >调查链接</el-button>
  164. </el-dropdown-item>
  165. <el-dropdown-item>
  166. <el-button type="text" @click="onCreateQRCode(scope.row, '统计链接')">统计链接</el-button>
  167. </el-dropdown-item>
  168. <el-dropdown-item>
  169. <el-button type="text" @click="onCreateQRCode(scope.row, '缴费链接')">缴费链接</el-button>
  170. </el-dropdown-item>
  171. </el-dropdown-menu>
  172. </el-dropdown>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <pagination
  178. sync
  179. :total.sync="rules.total"
  180. :page.sync="rules.page"
  181. :limit.sync="rules.limit"
  182. :page-sizes="rules.page_size"
  183. @pagination="getList"
  184. />
  185. </div>
  186. </div>
  187. <el-dialog
  188. :title="makeType == 'create' ? '生成链接' : '修改主题'"
  189. :visible.sync="makeUrlVisible"
  190. width="500px"
  191. v-if="makeUrlVisible"
  192. >
  193. <addUrl ref="addUrl" @close="close" :makeType="makeType" :makeDetail="makeDetail" @getList="getList" />
  194. <div slot="footer">
  195. <el-button @click="makeUrlVisible = false">取 消</el-button>
  196. <el-button type="primary" @click="addurl">保存</el-button>
  197. </div>
  198. </el-dialog>
  199. <el-dialog
  200. title="详情"
  201. :visible.sync="detailVisible"
  202. width="1200px"
  203. @close="getClose"
  204. v-if="detailVisible"
  205. >
  206. <detail ref="detail" @close="close" :detail="activeRow" />
  207. <div slot="footer">
  208. <el-button type="primary" @click="getClose"
  209. >确定</el-button
  210. >
  211. </div>
  212. </el-dialog>
  213. <qr-code v-model="qrcodeStatus" :title="qrcodeName" :codeUrl="codeUrl" />
  214. <!-- <el-dialog :title="qrcodeName" :visible.sync="qrcodeStatus" width="300px">
  215. <div class="left-code">
  216. <div id="qrcode" class="qrcode code" ref="qrCodeUrl"></div>
  217. <p class="code-url" v-if="codeUrl">
  218. <copy-text>
  219. {{ codeUrl }}
  220. </copy-text>
  221. </p>
  222. </div>
  223. </el-dialog> -->
  224. </div>
  225. </template>
  226. <script>
  227. import { permission } from "@/utils/directivePage";
  228. import { vaildStudentUrl, vaildTeachingUrl } from "@/utils/validate";
  229. import pagination from "@/components/Pagination/index";
  230. import addUrl from "./modals/addUrl";
  231. import detail from "./modals/detail";
  232. import { getReplacementList, openPayReplacement, updateReplacement } from "./api";
  233. import { Export } from '@/utils/downLoadFile'
  234. import cleanDeep from 'clean-deep'
  235. import qs from 'qs';
  236. import QrCode from "@/components/QrCode/index";
  237. import { encode } from 'js-base64';
  238. export default {
  239. components: { pagination, addUrl, detail, QrCode },
  240. data() {
  241. return {
  242. searchForm: {
  243. search: null,
  244. organId: "",
  245. openPay: "",
  246. },
  247. tableList: [],
  248. rules: {
  249. // 分页规则
  250. limit: 10, // 限制显示条数
  251. page: 1, // 当前页
  252. total: 0, // 总条数
  253. page_size: [10, 20, 40, 50], // 选择限制显示条数
  254. },
  255. makeUrlVisible: false,
  256. makeType: 'create',
  257. detailVisible: false,
  258. makeDetail: null,
  259. codeUrl: "",
  260. qrcodes: true,
  261. qrcodeStatus: false,
  262. qrcodeName: "调查链接",
  263. activeRow: null,
  264. };
  265. },
  266. //生命周期 - 创建完成(可以访问当前this实例)
  267. created() {},
  268. //生命周期 - 挂载完成(可以访问DOM元素)
  269. mounted() {
  270. // 获取分部
  271. this.init();
  272. },
  273. methods: {
  274. permission(str, parent) {
  275. return permission(str, parent);
  276. },
  277. init() {
  278. this.$store.dispatch("setBranchs");
  279. this.getList();
  280. },
  281. async getList() {
  282. try {
  283. const res = await getReplacementList({
  284. ...this.searchForm,
  285. page: this.rules.page,
  286. rows: this.rules.limit,
  287. });
  288. this.rules.total = res.data.total;
  289. this.tableList = res.data.rows;
  290. } catch (e) {
  291. }
  292. },
  293. search() {
  294. this.rules.page = 1;
  295. this.getList();
  296. },
  297. onReSet() {
  298. this.$refs.searchForm.resetFields();
  299. this.search();
  300. },
  301. makeUrl(type, row) {
  302. this.makeUrlVisible = true;
  303. this.makeType = type
  304. if(type == 'update') {
  305. this.makeDetail = row
  306. }
  307. },
  308. addurl() {
  309. this.$refs.addUrl.submit();
  310. },
  311. close() {
  312. this.makeUrlVisible = false;
  313. this.detailVisible = false;
  314. },
  315. getClose() {
  316. this.detailVisible = false
  317. this.getList()
  318. },
  319. async onExport() {
  320. const { search, ...rest } = this.searchForm;
  321. let obj = {
  322. ...rest,
  323. // activeType: 'REPLACEMENT',
  324. page: this.rules.page,
  325. rows: this.rules.limit,
  326. cooperationOrganIdOrName:search
  327. };
  328. await Export(
  329. this,
  330. {
  331. url: "/api-web/replacementInstrumentActivity/export",
  332. fileName: "乐器置换列表.xls",
  333. method: "post",
  334. params: qs.stringify(cleanDeep(obj)),
  335. },
  336. "您确定导出乐器置换列表"
  337. );
  338. },
  339. lookDetail(row, type) {
  340. if(type == 'answer') {
  341. this.$router.push({
  342. path: '/business/answer',
  343. query: {
  344. id: row.id,
  345. topicId: row.topicId
  346. }
  347. })
  348. } else {
  349. this.activeRow = row;
  350. this.detailVisible = true;
  351. }
  352. },
  353. onCreateQRCode(row, name) {
  354. // 生成链接
  355. this.qrcodeName = name;
  356. this.qrcodeStatus = true;
  357. let id = this.$route.query.id;
  358. if (this.qrcodes) {
  359. this.qrcodes = false;
  360. // setTimeout(() => {
  361. // document.getElementById("qrcode").innerHTML = "";
  362. // this.qrcode = new QRCode("qrcode", {
  363. // width: 260,
  364. // height: 260,
  365. // colorDark: "#000000",
  366. // colorLight: "#ffffff",
  367. // correctLevel: QRCode.CorrectLevel.H,
  368. // });
  369. let str;
  370. if (name == "调查链接") {
  371. let returnUrl = vaildStudentUrl() + `/#/questionnaire?` + encodeURIComponent(encode(`id=${row.id}`));
  372. // (returnUrl)
  373. // let tempUrl =
  374. // vaildStudentUrl() +
  375. // `/#/transfer?returnUrl=${encodeURIComponent(returnUrl)}`;
  376. str = returnUrl;
  377. } else if (name == "统计链接") {
  378. str =
  379. vaildTeachingUrl() +
  380. `/#/questionStatistics?o=${row.organId}&c=${row.cooperationOrganId}&id=${row.id}`;
  381. } else if(name == '缴费链接') {
  382. str = vaildStudentUrl() + `/#/questionGoodsSale?` + encodeURIComponent(encode(`rid=${row.id}`));
  383. }
  384. // vaildTeachingUrl
  385. // this.qrcode.makeCode(
  386. // str +
  387. // `/#/questionnaireInfo?o=${row.organId}&c=${row.cooperationOrganId}`
  388. // );
  389. this.codeUrl = str;
  390. this.qrcodes = true;
  391. // }, 100);
  392. }
  393. },
  394. openPay(row) {
  395. this.$confirm("确定开启缴费?", "提示", {
  396. confirmButtonText: "确定",
  397. cancelButtonText: "取消",
  398. type: "warning",
  399. })
  400. .then(async () => {
  401. try {
  402. const res = await openPayReplacement({ id: row.id });
  403. this.$message.success("开启缴费成功");
  404. this.getList();
  405. } catch (e) {
  406. }
  407. })
  408. .catch(() => {});
  409. },
  410. },
  411. };
  412. </script>
  413. <style lang='scss' scoped>
  414. .btnList {
  415. display: flex;
  416. flex-direction: row;
  417. justify-content: flex-start;
  418. }
  419. .code-url {
  420. margin-top: 10px;
  421. }
  422. </style>