index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="销售" prop="nickName">
  5. <el-select v-model="queryParams.companyUserId" remote placeholder="请选择" filterable clearable style="width: 100%;" @keyup.enter.native="handleQuery">
  6. <el-option
  7. v-for="dict in companyUserList"
  8. :key="`${dict.nickName} - ${dict.userName}`"
  9. :label="`${dict.nickName} - ${dict.userName}`"
  10. :value="dict.userId">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="类别" prop="type">
  15. <el-select v-model="queryParams.type" placeholder="请选择类别" clearable size="small">
  16. <el-option
  17. v-for="dict in typeOptions"
  18. :key="dict.dictValue"
  19. :label="dict.dictLabel"
  20. :value="dict.dictValue"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  26. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  30. <el-tabs type="card" v-model="actName" @tab-click="handleClickX">
  31. <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  32. </el-tabs>
  33. <el-table border v-loading="loading" :data="QwWorkTaskList" @selection-change="handleSelectionChange">
  34. <el-table-column type="selection" width="55" align="center" />
  35. <!-- <el-table-column label="客户昵称" align="center" prop="name" />-->
  36. <!-- <el-table-column label="企微账号" align="center" prop="qwUserName" />-->
  37. <el-table-column label="销售名称" align="center" prop="companyUserName" />
  38. <el-table-column label="状态" align="center" prop="status">
  39. <template slot-scope="scope">
  40. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="类别" align="center" prop="typeText">
  44. <template slot-scope="scope">
  45. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="标题" align="center" prop="title" />
  49. <el-table-column label="备注" align="center" prop="remark" />
  50. <el-table-column label="分值" align="center" prop="score">
  51. <template slot-scope="scope">
  52. <span :style="getScoreStyle(scope.row.score)">{{ scope.row.score }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="sop编号" align="center" prop="sopId" />
  56. <el-table-column label="公司id" align="center" prop="companyName" />
  57. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  58. <template slot-scope="scope">
  59. <el-button v-if="scope.row.status==0"
  60. size="mini"
  61. type="text"
  62. icon="el-icon-edit"
  63. @click="handleUpdate(scope.row)"
  64. >处理</el-button>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination
  69. v-show="total>0"
  70. :total="total"
  71. :page.sync="queryParams.pageNum"
  72. :limit.sync="queryParams.pageSize"
  73. @pagination="getList"
  74. />
  75. <!-- 添加或修改企微任务看板对话框 -->
  76. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  77. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  78. <el-form-item label="备注" prop="remark">
  79. <el-input v-model="form.remark" placeholder="请输入备注" type="textarea" :rows="3"/>
  80. </el-form-item>
  81. </el-form>
  82. <div slot="footer" class="dialog-footer">
  83. <el-button type="primary" @click="submitForm">确 定</el-button>
  84. <el-button @click="cancel">取 消</el-button>
  85. </div>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import { listQwWorkTask, getQwWorkTask, delQwWorkTask, addQwWorkTask, updateQwWorkTask, exportQwWorkTask } from "@/api/qw/QwWorkTask";
  91. import {getMyQwUserList, getMyQwCompanyList, handleInputAuthAppKey, updateUser} from "@/api/qw/user";
  92. import {getUserList} from "@/api/company/companyUser";
  93. export default {
  94. name: "QwWorkTask",
  95. data() {
  96. return {
  97. actName:"0",
  98. // 遮罩层
  99. loading: false,
  100. // 导出遮罩层
  101. exportLoading: false,
  102. // 选中数组
  103. ids: [],
  104. myQwUserList:[],
  105. companyUserList: [],
  106. // 非单个禁用
  107. single: true,
  108. // 非多个禁用
  109. multiple: true,
  110. // 显示搜索条件
  111. showSearch: true,
  112. // 总条数
  113. total: 0,
  114. // 企微任务看板表格数据
  115. QwWorkTaskList: [],
  116. // 弹出层标题
  117. title: "",
  118. // 是否显示弹出层
  119. open: false,
  120. // 状态 0 待处理 1 已处理 3 过期字典
  121. statusOptions: [],
  122. // 类别 1先导 2 课程 3 大小转 4 转人工字典
  123. typeOptions: [],
  124. // 查询参数
  125. queryParams: {
  126. pageNum: 1,
  127. pageSize: 10,
  128. extId: null,
  129. status: 0,
  130. qwUserId: null,
  131. type: null,
  132. title: null,
  133. score: null,
  134. sopId: null,
  135. companyId: null,
  136. companyUserId: null,
  137. },
  138. // 表单参数
  139. form: {},
  140. // 表单校验
  141. rules: {
  142. }
  143. };
  144. },
  145. created() {
  146. this.getDicts("sys_qw_work_task_status").then(response => {
  147. this.statusOptions = response.data;
  148. });
  149. this.getDicts("sys_qw_work_task_type").then(response => {
  150. this.typeOptions = response.data;
  151. });
  152. getUserList().then(res=>{
  153. if(res.code === 200) {
  154. this.companyUserList = res.data
  155. }
  156. })
  157. this.handleGetMyQwUserList();
  158. this.getList();
  159. },
  160. methods: {
  161. getScoreStyle(score) {
  162. let backgroundColor = '';
  163. if (score >= 15) {
  164. backgroundColor = '#ff4d4f'; // 红色
  165. } else if (score >= 9) {
  166. backgroundColor = '#ff7d45'; // 橘红
  167. } else if (score >= 4) {
  168. backgroundColor = '#ffec3d'; // 黄色
  169. } else {
  170. backgroundColor = '#ffffff'; // 白色
  171. }
  172. return {
  173. 'background-color': backgroundColor,
  174. 'padding': '5px 10px',
  175. 'border-radius': '4px'
  176. };
  177. },
  178. /** 查询企微任务看板列表 */
  179. getList() {
  180. this.loading = true;
  181. listQwWorkTask(this.queryParams).then(response => {
  182. this.QwWorkTaskList = response.rows;
  183. this.total = response.total;
  184. }).finally(() => {
  185. this.loading = false;
  186. });
  187. },
  188. handleClickX(tab, event) {
  189. this.queryParams.status=tab.name;
  190. this.handleQuery();
  191. },
  192. // 取消按钮
  193. cancel() {
  194. this.open = false;
  195. this.reset();
  196. },
  197. // 表单重置
  198. reset() {
  199. this.form = {
  200. id: null,
  201. extId: null,
  202. qwUserId: null,
  203. status: 0,
  204. type: null,
  205. title: null,
  206. remark: null,
  207. score: null,
  208. sopId: null,
  209. companyId: null,
  210. companyUserId: null,
  211. createTime: null,
  212. updateTime: null
  213. };
  214. this.resetForm("form");
  215. },
  216. /** 搜索按钮操作 */
  217. handleQuery() {
  218. this.queryParams.pageNum = 1;
  219. this.getList();
  220. },
  221. handleGetMyQwUserList(){
  222. getMyQwUserList().then(response => {
  223. this.myQwUserList = response.data;
  224. if(this.myQwUserList!=null){
  225. // this.queryParams.qwUserId=this.myQwUserList[0].dictValue
  226. this.queryParams.corpId=this.myQwUserList[0].corpId
  227. this.getList();
  228. }
  229. });
  230. },
  231. /** 重置按钮操作 */
  232. resetQuery() {
  233. this.resetForm("queryForm");
  234. this.handleQuery();
  235. },
  236. // 多选框选中数据
  237. handleSelectionChange(selection) {
  238. this.ids = selection.map(item => item.id)
  239. this.single = selection.length!==1
  240. this.multiple = !selection.length
  241. },
  242. /** 新增按钮操作 */
  243. handleAdd() {
  244. this.reset();
  245. this.open = true;
  246. this.title = "添加企微任务看板";
  247. },
  248. /** 修改按钮操作 */
  249. handleUpdate(row) {
  250. this.reset();
  251. const id = row.id || this.ids
  252. this.form = row;
  253. this.open = true;
  254. this.title = "处理任务";
  255. },
  256. /** 提交按钮 */
  257. submitForm() {
  258. this.$refs["form"].validate(valid => {
  259. if (valid) {
  260. if (this.form.id != null) {
  261. updateQwWorkTask(this.form).then(response => {
  262. this.msgSuccess("修改成功");
  263. this.open = false;
  264. this.getList();
  265. });
  266. } else {
  267. addQwWorkTask(this.form).then(response => {
  268. this.msgSuccess("新增成功");
  269. this.open = false;
  270. this.getList();
  271. });
  272. }
  273. }
  274. });
  275. },
  276. /** 删除按钮操作 */
  277. handleDelete(row) {
  278. const ids = row.id || this.ids;
  279. this.$confirm('是否确认删除企微任务看板编号为"' + ids + '"的数据项?', "警告", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning"
  283. }).then(function() {
  284. return delQwWorkTask(ids);
  285. }).then(() => {
  286. this.getList();
  287. this.msgSuccess("删除成功");
  288. }).catch(() => {});
  289. },
  290. /** 导出按钮操作 */
  291. handleExport() {
  292. const queryParams = this.queryParams;
  293. this.$confirm('是否确认导出所有企微任务看板数据项?', "警告", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning"
  297. }).then(() => {
  298. this.exportLoading = true;
  299. return exportQwWorkTask(queryParams);
  300. }).then(response => {
  301. this.download(response.msg);
  302. }).catch(() => {})
  303. .finally(()=>{
  304. this.exportLoading = false;
  305. })
  306. }
  307. }
  308. };
  309. </script>