index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="table-box">
  3. <LjVxeTable
  4. ref="VxeTableRef"
  5. row-key="springid"
  6. :columns="columns"
  7. :request-api="getData"
  8. :data-callback="dataCallback"
  9. :dwname="dwname"
  10. :table-props="tableProps"
  11. :table-events="tableEvents"
  12. :tool-button="['export', 'refresh', 'setting', 'search', 'location']"
  13. :auto-load-layout="false"
  14. pagination
  15. >
  16. <!-- 表格 header 按钮 -->
  17. <template #tableHeader>
  18. <el-button-group>
  19. <el-button @click="handleOpenNewTable">{{ $t("common.add") }}</el-button>
  20. <el-button @click="fDelete">{{ $t("common.delText") }}</el-button>
  21. <el-button @click="fAudit(0)">{{ $t("common.auditText") }}</el-button>
  22. <el-button @click="fAudit(1)">{{ $t("common.withdrawAuditText") }}</el-button>
  23. <el-button @click="fAudit(2)">{{ $t("common.disable") }}</el-button>
  24. <el-button @click="fAudit(3)">{{ $t("common.enabled") }}</el-button>
  25. </el-button-group>
  26. </template>
  27. </LjVxeTable>
  28. </div>
  29. <LjDialog
  30. ref="LjDrawerRef"
  31. class="is-selector"
  32. v-bind="{
  33. ...drawerDefineProp
  34. }"
  35. :style="{ padding: 0 }"
  36. >
  37. <template #header>
  38. <div class="flx-1">
  39. <span class="text-h5-b">弹簧资料</span>
  40. </div>
  41. </template>
  42. <div class="flx-1 h-full">
  43. <LjHeaderMenu :data="mainData" :action="orderStatus ? orderEditAction : orderDefaultAction" />
  44. <Detail class="flx-1" :data="mainData" :status="orderStatus" :enum="enumMap" />
  45. </div>
  46. </LjDialog>
  47. </template>
  48. <script setup lang="ts" name="baseinfo_springlist">
  49. import { ref, onMounted, provide } from "vue";
  50. import { getSpringList } from "@/api/modules/basicinfo";
  51. import { ColumnProps } from "@/components/LjVxeTable/interface";
  52. import LjDrawer from "@/components/LjDrawer/index.vue";
  53. import Detail from "./detail.vue";
  54. import { useHooks } from "./hooks/index";
  55. import LjDialog from "@/components/LjDialog/index.vue";
  56. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  57. import { useI18n } from "vue-i18n";
  58. import { useAuthButtons } from "@/hooks/useAuthButtons";
  59. import { cloneDeep } from "lodash-es";
  60. const dwname = "web_springlist";
  61. const mainData = ref({});
  62. const tableProps = {
  63. height: "auto",
  64. editConfig: { trigger: "click", mode: "cell" }
  65. // rowClassName: rowClsNameFunc
  66. // exportConfig: {
  67. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  68. // }
  69. };
  70. const { t } = useI18n();
  71. const { VxeTableRef, LjDetailRef, columns, fDelete, fSave, fAudit } = useHooks(t);
  72. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  73. const orderStatus = ref("");
  74. const typename = ref("");
  75. const enumMap = ref(new Map());
  76. const orderDefaultAction = [
  77. buttonDefault({
  78. label: t("common.cancelText"),
  79. icon: "iconchevron-left"
  80. }),
  81. buttonNew({
  82. label: t("common.saveText"),
  83. icon: "iconsave-01",
  84. clickFunc: item => {
  85. const save_data = orderStatus.value == "new" ? LjDetailRef.value?.infoParam : LjDetailRef.value?._mainData;
  86. fSave({ spring: save_data }).then(() => {
  87. LjDrawerRef.value.hide();
  88. });
  89. }
  90. })
  91. ];
  92. const orderEditAction = [
  93. buttonNew({
  94. label: t("common.saveText"),
  95. icon: "iconsave-01",
  96. clickFunc: item => {
  97. const save_data = LjDetailRef.value?._mainData;
  98. fSave({ spring: save_data }).then(() => {
  99. LjDrawerRef.value.hide();
  100. });
  101. }
  102. })
  103. ];
  104. /*
  105. * @description 抽屉默认属性
  106. */
  107. const drawerDefineProp = {
  108. draggable: true,
  109. overflow: true,
  110. width: "40%"
  111. // modalClass: "lj-file-dialog"
  112. };
  113. const getData = (params: any) => {
  114. return getSpringList(params);
  115. };
  116. const dataCallback = (data: any) => {
  117. if (data.tableinfo?.columns) {
  118. data.tableinfo?.columns.map((item: any) => {
  119. if (item?.enum) {
  120. enumMap.value.set(item.field, item.enum);
  121. }
  122. });
  123. }
  124. return {
  125. list: data.datatable,
  126. tableinfo: data.tableinfo,
  127. total: data.totalcnt,
  128. pageNum: data.pageindex,
  129. pageSize: data.pagesize
  130. };
  131. };
  132. const LjDrawerRef = ref();
  133. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  134. // 弹窗
  135. mainData.value = cloneDeep(row);
  136. // typename.value = row.typename;
  137. orderStatus.value = "edit";
  138. LjDrawerRef.value.show();
  139. };
  140. const handleOpenNewTable = () => {
  141. mainData.value = {
  142. springid: 0
  143. };
  144. typename.value = "";
  145. orderStatus.value = "new";
  146. LjDrawerRef.value.show();
  147. };
  148. // 返回绑定的事件
  149. const tableEvents = {
  150. "cell-dblclick": handleDBlClickTable
  151. // "cell-click": handleClickTable
  152. };
  153. </script>