recordReview.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. ref="crud"
  5. :option="option"
  6. :page.sync="page"
  7. :search="searchForm"
  8. v-model="form"
  9. :data="list"
  10. :table-loading="tableLoading"
  11. @search-change="searchChange"
  12. @size-change="sizeChange"
  13. @current-change="currentChange"
  14. @search-reset="searchReset"
  15. @refresh-change="refreshChange"
  16. >
  17. <!-- 操作栏 -->
  18. <template slot="menu" slot-scope="scope">
  19. <el-button
  20. type="text"
  21. size="small"
  22. icon="el-icon-edit"
  23. @click="recordReviewFn(scope.row, scope.index)"
  24. >审核
  25. </el-button></template
  26. >
  27. <!-- 派工方搜索 -->
  28. <template slot="deptIdSearch">
  29. <el-select v-model="searchForm.deptId" clearable>
  30. <el-option
  31. v-for="item in deptLists"
  32. :key="item.deptId"
  33. :label="item.name"
  34. :value="item.deptId"
  35. >
  36. </el-option>
  37. </el-select>
  38. </template>
  39. <!-- 区域搜索 -->
  40. <template slot="areaCodesSearch">
  41. <el-cascader
  42. @change="searchFormAreaCodesChange"
  43. v-model="searchFormAreaCodes"
  44. :options="treeList"
  45. :key="cascaderKey"
  46. collapse-tags
  47. :props="searchCascaderProps"
  48. clearable
  49. ></el-cascader>
  50. </template>
  51. <!-- 角色 -->
  52. <template slot="role" slot-scope="scope">
  53. <span v-for="(role, index) in scope.row.roleList" :key="index">
  54. <el-tag>{{ role.roleName }} </el-tag>&nbsp;&nbsp;
  55. </span>
  56. </template>
  57. </avue-crud>
  58. <!-- 新增沟通专员 -->
  59. <communicationOfficerDialog
  60. @addSuccess="refreshChange"
  61. ref="communicationOfficerRef"
  62. />
  63. </basic-container>
  64. </template>
  65. <script>
  66. import communicationOfficerDialog from "./components/communicationOfficerDialog.vue";
  67. import { recordReviewTableOption } from "@/const/crud/admin/user";
  68. import { fetchList } from "@/api/admin/user";
  69. import { getAreaTreeApi } from "@/api/areaTree";
  70. import { getListByDeptApi } from "@/api/admin/role";
  71. export default {
  72. components: { communicationOfficerDialog },
  73. data() {
  74. return {
  75. form: {},
  76. searchFormAreaCodes: [],
  77. searchForm: {
  78. certType: "",
  79. areaCodes: []
  80. },
  81. page: {
  82. total: 0, // 总页数
  83. currentPage: 1, // 当前页数
  84. pageSize: 20, // 每页显示多少条,
  85. isAsc: false // 是否倒序
  86. },
  87. option: recordReviewTableOption,
  88. tableLoading: false,
  89. list: [],
  90. deptLists: [],
  91. treeList: [],
  92. cascaderKey: 0,
  93. searchCascaderProps: {
  94. multiple: true,
  95. label: "name",
  96. value: "id"
  97. }
  98. };
  99. },
  100. created() {
  101. this.getList(this.page);
  102. this.getListByDept();
  103. this.getAreaTree();
  104. },
  105. methods: {
  106. async getAreaTree() {
  107. const res = await getAreaTreeApi();
  108. console.log("res", res);
  109. this.treeList = res.data.data;
  110. },
  111. async getListByDept() {
  112. const res = await getListByDeptApi();
  113. console.log("res getListByDeptApi", res);
  114. this.deptLists = res.data.data;
  115. },
  116. searchFormAreaCodesChange(e) {
  117. console.log("e", e);
  118. },
  119. // 获取列表
  120. async getList(page, params) {
  121. this.tableLoading = true;
  122. const obj = Object.assign(
  123. {
  124. current: page.currentPage,
  125. size: page.pageSize
  126. },
  127. params,
  128. this.searchForm
  129. );
  130. obj.role = obj.role ? [obj.role] : [5];
  131. const res = await fetchList(obj);
  132. res.data.data.records.forEach(item => {
  133. if (item.roleList.length) {
  134. item.role = item.roleList.map(iten => iten.roleId);
  135. }
  136. });
  137. const records = res.data.data.records;
  138. this.list = records;
  139. this.page.total = res.data.data.total;
  140. this.tableLoading = false;
  141. },
  142. recordReviewFn(row) {
  143. this.$refs.communicationOfficerRef.reviewFn(row);
  144. console.log("row", row);
  145. },
  146. extractLastElements(array) {
  147. // 创建一个新的空数组来存储结果
  148. let result = [];
  149. // 遍历输入的二维数组
  150. for (let i = 0; i < array.length; i++) {
  151. // 检查内部数组是否非空
  152. if (array[i].length > 0) {
  153. // 将内部数组的最后一个元素添加到结果数组中
  154. result.push(array[i][array[i].length - 1]);
  155. }
  156. }
  157. // 返回结果数组
  158. return result;
  159. },
  160. // 搜索
  161. searchChange(param, done) {
  162. this.searchForm = param;
  163. if (this.searchFormAreaCodes.length) {
  164. const codes = this.extractLastElements(this.searchFormAreaCodes);
  165. this.searchForm.areaCodes = codes;
  166. }
  167. this.page.currentPage = 1;
  168. this.getList(this.page, param);
  169. done();
  170. },
  171. // page修改
  172. sizeChange(pageSize) {
  173. this.page.pageSize = pageSize;
  174. this.getList(this.page);
  175. },
  176. currentChange(current) {
  177. this.page.currentPage = current;
  178. this.getList(this.page);
  179. },
  180. refreshChange() {
  181. this.getList(this.page);
  182. },
  183. searchReset() {
  184. // this.searchForm = {};
  185. ++this.cascaderKey;
  186. this.searchFormAreaCodes = [];
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped></style>