UserManage.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div>
  3. <div class="menu-title">
  4. 用户管理
  5. </div>
  6. <div class="menu-content">
  7. <div>
  8. <el-form :inline="true" :model="qo" class="demo-form-inline">
  9. <el-form-item>
  10. <el-input v-model="qo.LIKES_fid" placeholder="请输入Fid"></el-input>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="qo.pageNo=1;queryData()">搜 索</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </div>
  17. <div style="margin: 0px 0 20px 0">
  18. <el-button type="primary" @click="createRow()">添加</el-button>
  19. </div>
  20. <div>
  21. <el-table :data="result.records" style="width: 100%">
  22. <el-table-column type="index" label="行号" width="60"></el-table-column>
  23. <el-table-column prop="fid" label="fid"></el-table-column>
  24. <el-table-column prop="labels" label="标签">
  25. <div slot-scope="scope">
  26. <template v-for="(tag,index) in scope.row.labelsArr">
  27. <el-tag :key="index" v-if="index < 5">{{ tag }}</el-tag>
  28. </template>
  29. <el-tag v-if="scope.row.labelsArr.length > 5">...</el-tag>
  30. </div>
  31. </el-table-column>
  32. <el-table-column label="操作" width="180">
  33. <template slot-scope="scope">
  34. <el-button @click.native.prevent="similarUser(scope.row)" type="text" size="small">
  35. 相似
  36. </el-button>
  37. <el-button @click.native.prevent="recommendItem(scope.row)" type="text" size="small">
  38. 洞悉
  39. </el-button>
  40. <el-button @click.native.prevent="modifyRow(scope.row)" type="text" size="small">
  41. 编辑
  42. </el-button>
  43. <el-button @click.native.prevent="removeRow(scope.row)" type="text" size="small">
  44. 删除
  45. </el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. </div>
  50. <div class="page-box">
  51. <el-pagination background
  52. @current-change="handleCurrentChange"
  53. :current-page="qo.pageNo"
  54. :page-size="qo.pageSize"
  55. layout="total, prev, pager, next"
  56. :total="result.total">
  57. </el-pagination>
  58. </div>
  59. </div>
  60. <el-dialog
  61. :title="dialogName"
  62. :visible.sync="cmdDialogVisible"
  63. width="40%">
  64. <el-form ref="cmd" label-width="100px" :rules="rules" :model="cmd">
  65. <el-form-item label="fid" prop="fid">
  66. <el-input v-model="cmd.fid" placeholder="请输入fid"></el-input>
  67. </el-form-item>
  68. </el-form>
  69. <span slot="footer" class="dialog-footer">
  70. <el-button @click="cmdDialogVisible = false">取 消</el-button>
  71. <el-button type="primary" @click="submitModify">确 定</el-button>
  72. </span>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import request from '@/utils/request';
  78. var _this;
  79. export default {
  80. name: "userManage",
  81. data() {
  82. return {
  83. qo: {
  84. pageNo: 1,
  85. pageSize: 10,
  86. LIKES_fid: '',
  87. },
  88. result: {
  89. records: [],
  90. total: 0
  91. },
  92. dialogName: '编辑',
  93. cmdDialogVisible: false,
  94. cmd: {},
  95. rules: {
  96. fid: [
  97. {required: true, message: '请输入fid'}
  98. ],
  99. },
  100. }
  101. },
  102. mounted() {
  103. _this = this;
  104. let _qo = _this.$route.query.qo;
  105. if (_qo) {
  106. _this.qo = JSON.parse(_qo);
  107. }
  108. _this.queryData();
  109. },
  110. methods: {
  111. queryData() {
  112. request({
  113. url: '/risk-user/query_pages',
  114. method: 'post',
  115. data: _this.qo
  116. }).then(res => {
  117. res.data.records.forEach(row => {
  118. row.labelsArr = row.labels ? row.labels.split(',') : [];
  119. });
  120. _this.result.records = res.data.records;
  121. _this.result.total = res.data.total;
  122. });
  123. },
  124. handleCurrentChange(val) {
  125. _this.qo.pageNo = val;
  126. _this.queryData();
  127. },
  128. similarUser(item) {
  129. _this.$router.push({
  130. path: "similarUser", query: {
  131. userId: item.fid,
  132. qo: JSON.stringify(_this.qo)
  133. }
  134. });
  135. },
  136. recommendItem(item) {
  137. _this.$router.push({
  138. path: "recommendItem", query: {
  139. userId: item.fid,
  140. qo: JSON.stringify(_this.qo)
  141. }
  142. });
  143. },
  144. removeRow(item) {
  145. _this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
  146. confirmButtonText: '确定',
  147. cancelButtonText: '取消',
  148. type: 'warning'
  149. }).then(() => {
  150. request({
  151. url: '/risk-user/remove/' + item.id,
  152. method: 'post'
  153. }).then(res => {
  154. _this.$message.success("删除成功");
  155. _this.queryData();
  156. });
  157. }).catch(() => {
  158. });
  159. },
  160. createRow() {
  161. _this.dialogName = '新建';
  162. _this.cmdDialogVisible = true;
  163. _this.$nextTick(_ => {
  164. _this.$refs['cmd'].clearValidate();
  165. _this.cmd = {
  166. fid: '',
  167. };
  168. })
  169. },
  170. modifyRow(item) {
  171. _this.dialogName = '编辑';
  172. _this.cmdDialogVisible = true;
  173. _this.$nextTick(_ => {
  174. _this.$refs['cmd'].clearValidate();
  175. _this.cmd = JSON.parse(JSON.stringify(item));
  176. })
  177. },
  178. submitModify() {
  179. this.$refs.cmd.validate((valid) => {
  180. if (valid) {
  181. if (_this.cmd.id) {
  182. request({
  183. url: '/risk-user/modify',
  184. method: 'post',
  185. data: _this.cmd
  186. }).then(res => {
  187. _this.$message.success("编辑成功");
  188. _this.queryData();
  189. _this.cmdDialogVisible = false;
  190. });
  191. } else { // 新建
  192. request({
  193. url: '/risk-user/create',
  194. method: 'post',
  195. data: _this.cmd
  196. }).then(res => {
  197. _this.$message.success("添加成功");
  198. _this.cmdDialogVisible = false;
  199. });
  200. }
  201. }
  202. });
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. </style>