平安校园
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.vue 6.1 KiB

7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
7 meses atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!--
  2. * @Description: 服装库管理
  3. * @Author: syy
  4. * @Date: 2024-7-18
  5. -->
  6. <template>
  7. <div class="main-box">
  8. <TreeFilter
  9. ref="treeFilter"
  10. label="clothSetName"
  11. id="clothSetId"
  12. width="300px"
  13. :show-all="true"
  14. :request-api="userManageClothApi.getList"
  15. @change="changeTreeFilter"
  16. >
  17. <template v-slot:header>
  18. <s-button suffix="服装库" @click="addClass(FormOptEnum.ADD)" style="margin-bottom: 15px" />
  19. </template>
  20. <template v-slot:label="{ row }">
  21. <span class="custom-tree-node">
  22. <span>{{ row.node.label }}</span>
  23. <span v-if="row.node.label != '全部'">
  24. <a @click.stop="addClass(FormOptEnum.EDIT, row.node.data)">
  25. <el-icon><Edit /></el-icon>
  26. </a>
  27. <a style="margin-left: 8px" @click.stop="addDelete(row.node.data.clothSetId, '删除服装库')">
  28. <el-icon><Delete /></el-icon>
  29. </a>
  30. </span>
  31. </span>
  32. </template>
  33. </TreeFilter>
  34. <div class="table-box">
  35. <ProTable ref="proTable" title="服装库管理" :columns="columns" rowKey="clothId" :data="tableData.clothes">
  36. <!-- 表格 header 按钮 -->
  37. <template #tableHeader="scope">
  38. <s-button suffix="服装" @click="onOpen(FormOptEnum.ADD, { clothSetId: clothSetId }, treeFilter.treeAllData)" />
  39. <s-button
  40. type="danger"
  41. :opt="FormOptEnum.DELETE"
  42. plain
  43. suffix="服装"
  44. :disabled="!scope.isSelected"
  45. @click="onDelete(scope.selectedListIds, '删除所选服装')"
  46. />
  47. </template>
  48. <!-- 表格操作栏 -->
  49. <template #operation="scope">
  50. <el-space>
  51. <s-button link :opt="FormOptEnum.DELETE" @click="onDelete([scope.row.clothId], `删除服装`)" />
  52. </el-space>
  53. </template>
  54. </ProTable>
  55. </div>
  56. <!-- 人员新增/编辑表单 -->
  57. <Form ref="formRef"></Form>
  58. <!-- 班级新增/编辑表单 -->
  59. <Form1 ref="formRefC" />
  60. <!-- 预览头像 -->
  61. <el-dialog v-model="visible" title="查看头像" width="830px" :before-close="handleClose">
  62. <div style="display: flex; align-items: center; justify-content: center">
  63. <img style="max-width: 100%; max-height: 600px" class="detailpic" :src="faceUrl" alt="" />
  64. </div>
  65. <template #footer>
  66. <div class="dialog-footer">
  67. <el-button @click="visible = false">关闭</el-button>
  68. </div>
  69. </template>
  70. </el-dialog>
  71. </div>
  72. </template>
  73. <script setup lang="tsx" name="SysUserClothing">
  74. import { userManageClothApi,userClothButtonCode,SysUserCloth } from "@/api";
  75. import { useHandleData } from "@/hooks/useHandleData";
  76. import { FormOptEnum } from "@/enums";
  77. import Form from "./components/form/index.vue";
  78. import Form1 from "./components/form1/index.vue";
  79. import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
  80. import TreeFilter from "@/components/TreeFilter/index.vue";
  81. import { useUserStore } from "@/stores/modules";
  82. // 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
  83. const faceUrl = ref('');
  84. const visible = ref(false); //是否显示人员表单
  85. const proTable = ref<ProTableInstance>();
  86. const treeFilter = ref<any>({});
  87. const userStore = useUserStore();
  88. const { accessToken } = userStore;
  89. const tableData = ref<any>([])
  90. // 表格配置项
  91. const columns: ColumnProps<SysUserCloth.list>[] = [
  92. { type: "selection", fixed: "left", width: 50 },
  93. {
  94. prop: "clothUrl",
  95. label: "服装图",
  96. render: scope => {
  97. return (
  98. <img src={scope.row.clothUrl} onClick={() => viewHeadImage(scope)} style='width:50px;height:50px' alt=''/>
  99. );
  100. }
  101. },
  102. { prop: "operation", label: "操作", width: 250, fixed: "right" }
  103. ];
  104. const viewHeadImage = (scope: any) => {
  105. faceUrl.value = scope.row.clothUrl;
  106. visible.value = true
  107. };
  108. const handleClose = () => {
  109. visible.value = false;
  110. };
  111. // 人员表单引用
  112. const formRef = ref<InstanceType<typeof Form> | null>(null);
  113. // 班级表单引用
  114. const formRefC = ref<InstanceType<typeof Form1> | null>(null);
  115. /**
  116. * 打开服装表单
  117. * @param opt 操作类型
  118. * @param record 记录
  119. */
  120. function onOpen(opt: FormOptEnum, record: {},treeAllData:any) {
  121. formRef.value?.onOpen({ opt: opt, record: record,treeAllData:treeAllData, successful: RefreshTable });
  122. }
  123. /**
  124. * 打开服装库表单
  125. * @param opt 操作类型
  126. * @param record 记录
  127. */
  128. function addClass(opt: FormOptEnum, record: {} | SysUserCloth.list = {}) {
  129. formRefC.value?.onOpen({ opt: opt, record: JSON.parse(JSON.stringify(record)), successful: RefreshTree });
  130. }
  131. /**
  132. * 服装库删除
  133. * @param ids id数组
  134. */
  135. async function addDelete(clothSetId: string[],msg: string) {
  136. // 二次确认 => 请求api => 刷新表格
  137. await useHandleData(userManageClothApi.deleteClothDataBaseD, { clothSetId }, msg);
  138. RefreshTree(); //刷新表格
  139. }
  140. /**
  141. * 服装删除
  142. * @param ids id数组
  143. */
  144. async function onDelete(ids: string[], msg: string) {
  145. // 二次确认 => 请求api => 刷新表格
  146. await useHandleData(userManageClothApi.delete, {clothId: ids.join(","), clothSetId:tableData.value.clothSetId}, msg);
  147. RefreshTable(); //刷新表格
  148. }
  149. // 刷新表格
  150. const RefreshTable = () => {
  151. getList(clothSetId.value)
  152. }
  153. // 刷新表格+树
  154. const RefreshTree = () => {
  155. getList(clothSetId.value)
  156. treeFilter.value?.refresh(); //刷新树形筛选器
  157. }
  158. /** 服装库切换切换 */
  159. const clothSetId = ref<number | string>()
  160. function changeTreeFilter(val: number | string) {
  161. clothSetId.value = val
  162. proTable.value!.pageable.pageNum = 1;
  163. getList(val)
  164. }
  165. // 获取列表
  166. const getList = (clothSetId:any)=>{
  167. if(!clothSetId) return false
  168. userManageClothApi.page({clothSetId:clothSetId}).then((resp:any)=>{
  169. if(resp.code == 200){
  170. tableData.value = resp.data
  171. }
  172. })
  173. }
  174. </script>
  175. <style scoped lang="scss">
  176. .table-box {
  177. width: 100%;
  178. height: 100%;
  179. }
  180. .custom-tree-node {
  181. display: flex;
  182. flex: 1;
  183. align-items: center;
  184. justify-content: space-between;
  185. padding-right: 8px;
  186. font-size: 14px;
  187. }
  188. </style>