index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <LjFoldLayout ref="LjFoldLayoutRef" v-bind="layoutSetting">
  3. <div class="main-box flx-col">
  4. <LjVxeTable
  5. ref="VxeTableRef"
  6. row-key="varid"
  7. :columns="columns"
  8. :request-api="getData"
  9. :data-callback="dataCallback"
  10. :dwname="dwname"
  11. :table-props="tableProps"
  12. :table-events="tableEvents"
  13. :init-param="initParams"
  14. :auto-load-layout="false"
  15. pagination
  16. >
  17. <!-- 表格 header 按钮 -->
  18. <template #tableHeader>
  19. <el-button-group>
  20. <el-button @click="handleOpenNewTable">{{ $t("common.add") }}</el-button>
  21. <el-button @click="fDelete">{{ $t("common.delText") }}</el-button>
  22. </el-button-group>
  23. <el-tabs v-model="initParams.varkind" class="tableheader-tabs">
  24. <el-tab-pane label="床网" :name="0"></el-tab-pane>
  25. <el-tab-pane label="床垫" :name="1"></el-tab-pane>
  26. </el-tabs>
  27. </template>
  28. </LjVxeTable>
  29. </div>
  30. <template #right>
  31. <div class="main-box flx-col">
  32. <LjVxeTable
  33. row-key="varmxid"
  34. :columns="columns_mx"
  35. :init-param="initParams_mx"
  36. :request-api="getMxData"
  37. :data-callback="dataMxCallback"
  38. :dwname="dwname_mx"
  39. :table-props="tableMxProps"
  40. :auto-load-layout="false"
  41. :collapse-buttons="true"
  42. pagination
  43. :table-button="[]"
  44. >
  45. </LjVxeTable>
  46. </div>
  47. </template>
  48. </LjFoldLayout>
  49. <LjDialog
  50. ref="LjDrawerRef"
  51. class="is-selector"
  52. v-bind="{
  53. ...drawerDefineProp
  54. }"
  55. :style="{ padding: 0 }"
  56. >
  57. <template #header>
  58. <div class="flx-1">
  59. <span class="text-h5-b">变量名称: {{ varname }}</span>
  60. </div>
  61. </template>
  62. <div class="flx-1 h-full">
  63. <LjHeaderMenu :data="mainData" :action="orderStatus ? orderEditAction : orderDefaultAction" />
  64. <Detail class="flx-1" :data="mainData" :status="orderStatus" :enum="enumMap" />
  65. </div>
  66. </LjDialog>
  67. </template>
  68. <script setup lang="ts" name="baseinfo_bednetvarlist">
  69. import { ref, onMounted, provide } from "vue";
  70. import { getBedNetVarList, getBedNetVarMxList } from "@/api/modules/basicinfo";
  71. import { ColumnProps } from "@/components/LjVxeTable/interface";
  72. import LjDrawer from "@/components/LjDrawer/index.vue";
  73. import Detail from "./detail.vue";
  74. import { useHooks } from "./hooks/index";
  75. import LjDialog from "@/components/LjDialog/index.vue";
  76. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  77. import { useI18n } from "vue-i18n";
  78. import { useAuthButtons } from "@/hooks/useAuthButtons";
  79. import { cloneDeep } from "lodash-es";
  80. import LjFoldLayout from "@/components/LjFoldLayout/index.vue";
  81. const dwname = "web_bednetvarlist";
  82. const dwname_mx = "web_bednetvarmxlist";
  83. const mainData = ref({});
  84. const tableProps = {
  85. height: "auto",
  86. editConfig: { trigger: "click", mode: "cell" }
  87. // rowClassName: rowClsNameFunc
  88. // exportConfig: {
  89. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  90. // }
  91. };
  92. const tableMxProps = {
  93. // height: "",
  94. // minHeight: "300px"
  95. height: "auto"
  96. // editConfig: { trigger: "click", mode: "cell" }
  97. // rowClassName: rowClsNameFunc
  98. // exportConfig: {
  99. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  100. // }
  101. };
  102. const layoutSetting = {
  103. dwname: dwname,
  104. right: {
  105. hidden: false
  106. }
  107. };
  108. const { t } = useI18n();
  109. const { VxeTableRef, LjDetailRef, VxeTableMxRef, columns, columns_mx, fDelete, fSave, fChangeBedNetType } = useHooks(t, null);
  110. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  111. const orderStatus = ref("");
  112. const varname = ref("");
  113. const enumMap = ref(new Map());
  114. const initParams = ref({ varkind: 0 });
  115. const initParams_mx = ref({ varid: 0 });
  116. const orderDefaultAction = [
  117. buttonDefault({
  118. label: t("common.cancelText"),
  119. icon: "iconchevron-left"
  120. }),
  121. buttonNew({
  122. label: t("common.saveText"),
  123. icon: "iconsave-01",
  124. clickFunc: item => {
  125. const save_data = orderStatus.value == "new" ? LjDetailRef.value?.infoParam : LjDetailRef.value?._mainData;
  126. // fSave({ bednetvar: save_data }).then(() => {
  127. // LjDrawerRef.value.hide();
  128. // });
  129. }
  130. })
  131. ];
  132. const orderEditAction = [
  133. buttonNew({
  134. label: t("common.saveText"),
  135. icon: "iconsave-01",
  136. clickFunc: item => {
  137. const save_data = orderStatus.value == "new" ? LjDetailRef.value?.infoParam : LjDetailRef.value?._mainData;
  138. save_data.mxlist = VxeTableMxRef.value?.tableData;
  139. fSave({ bednetvar: save_data }).then(() => {
  140. LjDrawerRef.value.hide();
  141. });
  142. }
  143. })
  144. ];
  145. /*
  146. * @description 抽屉默认属性
  147. */
  148. const drawerDefineProp = {
  149. draggable: true,
  150. overflow: true,
  151. width: "40%"
  152. // modalClass: "lj-file-dialog"
  153. };
  154. const getData = (params: any) => {
  155. return getBedNetVarList(params);
  156. };
  157. const getMxData = (params: any) => {
  158. return getBedNetVarMxList(params);
  159. };
  160. const dataMxCallback = (data: any) => {
  161. if (data.tableinfo?.columns) {
  162. data.tableinfo?.columns.map((item: any) => {
  163. if (item?.enum) {
  164. enumMap.value.set(item.field, item.enum);
  165. }
  166. });
  167. }
  168. return {
  169. list: data.datatable,
  170. tableinfo: data.tableinfo,
  171. total: data.totalcnt,
  172. pageNum: data.pageindex,
  173. pageSize: data.pagesize
  174. };
  175. };
  176. const dataCallback = (data: any) => {
  177. if (data.tableinfo?.columns) {
  178. data.tableinfo?.columns.map((item: any) => {
  179. if (item?.enum) {
  180. enumMap.value.set(item.field, item.enum);
  181. }
  182. });
  183. }
  184. if (data.datatable && data.datatable.length) {
  185. let row = data.datatable[0];
  186. initParams_mx.value.varid = Number(row.varid);
  187. fChangeBedNetType(parseInt(row.varclass));
  188. }
  189. return {
  190. list: data.datatable,
  191. tableinfo: data.tableinfo,
  192. total: data.totalcnt,
  193. pageNum: data.pageindex,
  194. pageSize: data.pagesize
  195. };
  196. };
  197. const LjDrawerRef = ref();
  198. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  199. // 弹窗
  200. mainData.value = cloneDeep(row);
  201. varname.value = row.varname;
  202. orderStatus.value = "edit";
  203. LjDrawerRef.value.show();
  204. };
  205. const handleOpenNewTable = () => {
  206. mainData.value = {
  207. varid: 0,
  208. varclass: 0
  209. };
  210. varname.value = "";
  211. orderStatus.value = "new";
  212. LjDrawerRef.value.show();
  213. };
  214. /**
  215. * @description 单击表格单元格,非打开新窗口时,获取单据明细
  216. */
  217. const handleClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  218. initParams_mx.value.varid = Number(row.varid);
  219. fChangeBedNetType(parseInt(row.varclass));
  220. };
  221. // 返回绑定的事件
  222. const tableEvents = {
  223. "cell-dblclick": handleDBlClickTable,
  224. "cell-click": handleClickTable
  225. };
  226. </script>