performance.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="performance">
  3. <div class="title-box">
  4. <h3>员工绩效</h3>
  5. </div>
  6. <div class="padding-box">
  7. <div class="search-box"></div>
  8. </div>
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import usePagination from "@/hooks/usePagination";
  13. import { defineComponent, reactive, toRefs, ref } from "vue";
  14. import { onBeforeRouteUpdate } from "vue-router";
  15. // import { TableColumnOfYuewen } from "../_pageOptions/table_yuewen";
  16. //getPromotionList
  17. import {
  18. getPromotionList,
  19. addPromotionLInk,
  20. updateReportConfig,
  21. deletePromotion,
  22. } from "@/api";
  23. import { message } from "ant-design-vue";
  24. const PutDataIndex = defineComponent({
  25. components: {},
  26. setup() {
  27. let { tablePageOptions } = usePagination();
  28. const formRef = ref();
  29. const state = reactive({
  30. search: {
  31. name: "", // 推广员名称
  32. days: "", // 自定义天数 1~30天 无默认
  33. months: "", // 自定义月数 默认一个月
  34. dateType: "month", // 按月查询month/按天查询date
  35. month_range: "", // 按月查询 月范围
  36. date_range: "", // 按天查询 日期范围
  37. },
  38. addLink: {
  39. channel_id: "", // 推广链接id
  40. channel_name: "", // 渠道名
  41. book_name: "", // 作品名
  42. },
  43. list: ref<any[]>([]),
  44. visible: false, // 添加派单链接dialog
  45. rateVisible: false, // 添加派单链接dialog
  46. drawerVisible: false,
  47. confirmLoading: false, // 提交链接loading
  48. // columns: TableColumnOfYuewen,
  49. rate: 0, // 设置回传配置
  50. channelId: "",
  51. loading: false,
  52. rules: {
  53. channel_id: [
  54. { required: true, message: "请输入推广链接ID", trigger: "change" },
  55. ],
  56. channel_name: [
  57. { required: true, message: "请输入渠道名", trigger: "change" },
  58. ],
  59. book_name: [
  60. { required: true, message: "请输入作品名", trigger: "change" },
  61. ],
  62. },
  63. });
  64. return { ...toRefs(state), formRef, tablePageOptions };
  65. },
  66. mounted() {
  67. this.getList({ current: 1 });
  68. },
  69. methods: {
  70. // 重置搜索条件
  71. resetSearch() {
  72. // this.search.book_name = "";
  73. // this.search.channel_name = "";
  74. // this.search.channel_id = "";
  75. },
  76. // 获取推广链接数据
  77. async getList(page?: any) {
  78. // this.loading = true;
  79. // let { data } = await getPromotionList({
  80. // page: page ? page.current : 1,
  81. // ...this.search,
  82. // });
  83. // this.loading = false;
  84. // this.list = data.list;
  85. },
  86. // 点击添加链接
  87. onAddLink() {
  88. this.addLink.channel_id = "";
  89. this.addLink.channel_name = "";
  90. this.addLink.book_name = "";
  91. this.visible = true;
  92. },
  93. // 确认增加派单链接
  94. async onEmitLink() {
  95. this.formRef.validate().then(() => {});
  96. if (!this.addLink.channel_name) return message.warn("请输入渠道名称");
  97. if (!this.addLink.channel_id) return message.warn("请输入链接ID");
  98. if (!this.addLink.book_name) return message.warn("请输入推广作品");
  99. try {
  100. await addPromotionLInk(this.addLink);
  101. message.success("新增成功");
  102. this.getList({ current: 1 });
  103. this.visible = false;
  104. } catch (err) {
  105. console.log("ERROR:", err);
  106. }
  107. },
  108. // 删除
  109. async onDelete(val: any) {
  110. try {
  111. await deletePromotion({ channel_id: val.channel_id });
  112. this.getList({ current: 1 });
  113. message.success("删除成功");
  114. } catch (err) {
  115. console.log(err);
  116. }
  117. },
  118. // 点击回传配置
  119. onRateConfig(val: any) {
  120. this.channelId = val.channel_id;
  121. this.rateVisible = true;
  122. this.rate = val.rate;
  123. },
  124. // 提交回传配置
  125. async onEmitRate() {
  126. if (this.rate > 100 || this.rate < 0)
  127. return message.error("回传比例应在0~100之间");
  128. if (parseInt(this.rate) !== parseFloat(this.rate))
  129. return message.warn("请输入整数");
  130. try {
  131. await updateReportConfig({
  132. channel_id: this.channelId,
  133. rate: this.rate,
  134. });
  135. message.success("修改成功");
  136. this.getList({ current: 1 });
  137. this.rateVisible = false;
  138. } catch (err) {
  139. console.log(err);
  140. }
  141. },
  142. // 查看注册用户
  143. openUserDrawer(val: any) {
  144. this.channelId = val.channel_id;
  145. this.drawerVisible = true;
  146. },
  147. },
  148. });
  149. export default PutDataIndex;
  150. </script>
  151. <style lang="scss" scoped>
  152. @import "@/assets/common-style/frame.scss";
  153. // .performance {
  154. // }
  155. </style>