index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <el-row :gutter="12" class="userlist w-full h-full">
  3. <el-col :span="4" class="h-full overflow-auto">
  4. <aside class="userlist__aside">
  5. <el-affix
  6. target=".userlist__aside"
  7. class="userlist__aside-header"
  8. :offset="globalStore.assemblySize == 'small' ? 84 : 90"
  9. >
  10. <LjHeader class="flx-1" :title="$t('business.detail.basicTitle')">
  11. <template #toolButton>
  12. <el-button type="primary" text :icon="Plus" :disabled="orderStatus != ''" @click="handleAdd">{{
  13. $t("common.addText")
  14. }}</el-button>
  15. </template>
  16. </LjHeader>
  17. <div class="userlist__aside-searchbox">
  18. <el-input v-model="searchInput" size="default" clearable @input="disshow">
  19. <template #prefix>
  20. <el-icon class="el-input__icon"><Search /></el-icon>
  21. </template>
  22. </el-input>
  23. </div>
  24. </el-affix>
  25. <el-empty v-if="!userListData.length" :image-size="120" description="暂无数据" />
  26. <!-- <LoadingCom /> -->
  27. <LjViewItem
  28. v-for="(item, index) in showUserList"
  29. :key="index"
  30. v-bind="fileClassListLayout"
  31. keyattr="empid"
  32. :current="initParams.empid"
  33. :data="item"
  34. @click-item="handleSelectItem"
  35. />
  36. </aside>
  37. </el-col>
  38. <el-col :span="20" class="h-full overflow-auto">
  39. <Detail
  40. ref="detailRef"
  41. :data="mainData"
  42. :status="orderStatus"
  43. @edit="handleEdit"
  44. @cancel="handleCancel"
  45. @del="handleDel"
  46. @goto="autoGotoUser"
  47. @unlock="handleUnLock"
  48. />
  49. </el-col>
  50. </el-row>
  51. </template>
  52. <script setup lang="tsx" name="saleprice_priclist">
  53. import { ref, onMounted, provide, nextTick } from "vue";
  54. import { getUserList, getSysFuncPwr, getDept, delUserList, UnLockUser } from "@/api/modules/basicinfo";
  55. import { getPriceList } from "@/api/modules/saleprice";
  56. import { ColumnProps } from "@/components/LjVxeTable/interface";
  57. import LjDrawer from "@/components/LjDrawer/index.vue";
  58. import Detail from "./detail.vue";
  59. import { useHooks } from "./hooks/index";
  60. import LjDialog from "@/components/LjDialog/index.vue";
  61. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  62. import { useI18n } from "vue-i18n";
  63. import { useAuthButtons } from "@/hooks/useAuthButtons";
  64. import LjViewItem from "@/components/LjViewItem/index.vue";
  65. import variables from "@/styles/js.module.scss";
  66. import { Files, Search, Plus } from "@element-plus/icons-vue";
  67. import LjHeader from "@/components/LjHeader/index.vue";
  68. import { useGlobalStore } from "@/stores/modules/global";
  69. import { ElMessage, ElMessageBox } from "element-plus";
  70. import { cloneDeep, pick, throttle } from "lodash-es";
  71. import { pinyinFilterTree } from "@/utils/pinyin";
  72. // const dwname = "web_pricelist";
  73. const mainData = ref({});
  74. // const tableProps = {
  75. // height: "auto",
  76. // editConfig: { trigger: "click", mode: "cell" }
  77. // // rowClassName: rowClsNameFunc
  78. // // exportConfig: {
  79. // // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  80. // // }
  81. // };
  82. const globalStore = useGlobalStore();
  83. const { t } = useI18n();
  84. const { orderStatus } = useHooks();
  85. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  86. provide("orderStatus", orderStatus);
  87. const detailRef = ref();
  88. const headername = ref("");
  89. const currentRow = ref<any>({});
  90. const searchInput = ref("");
  91. const _variables: any = variables;
  92. const initParams = ref({
  93. empid: -1
  94. });
  95. const userListData = ref<any>([]);
  96. const showUserList = ref<any>([]);
  97. const userListLoading = ref(false);
  98. provide("userListData", userListData);
  99. const sysFuncPwrData = ref<any>([]);
  100. provide("sysFuncPwrData", sysFuncPwrData);
  101. const deptData = ref<any>([]);
  102. provide("deptData", deptData);
  103. const priceListData = ref<any>([]);
  104. provide("priceListData", priceListData);
  105. // const orderDefaultAction = [
  106. // buttonDefault({
  107. // label: t("common.cancelText"),
  108. // icon: "iconchevron-left",
  109. // path: "/saletask/sale/saletaskCrm/new"
  110. // }),
  111. // buttonNew({
  112. // label: t("common.saveText"),
  113. // icon: "iconsave-01",
  114. // path: "/saletask/sale/saletaskCrm/new"
  115. // })
  116. // ];
  117. // const orderEditAction = [
  118. // buttonNew({
  119. // label: t("common.saveText"),
  120. // icon: "iconsave-01",
  121. // path: "/saletask/sale/saletaskCrm/new"
  122. // })
  123. // ];
  124. const fileClassListLayout = ref<any>({
  125. header: [
  126. {
  127. value: "username",
  128. icon: (item: any) => {
  129. return item.isLocked ? <i class={["iconfont", "iconLock_light"]} /> : "";
  130. }
  131. },
  132. {
  133. value: "descrp",
  134. label: "描述"
  135. }
  136. ],
  137. aside: {
  138. value: "userid",
  139. label: "ID"
  140. }
  141. });
  142. /**
  143. * @description 点击列表
  144. */
  145. const handleSelectItem = (data: any) => {
  146. let _data = cloneDeep(data);
  147. if (orderStatus.value) {
  148. ElMessageBox.confirm(t("business.detail.edittingQuit"), t("sys.app.warning"), {
  149. confirmButtonText: t("common.quit"),
  150. cancelButtonText: t("common.cancelText"),
  151. type: "warning"
  152. }).then(() => {
  153. handleCancel(_data);
  154. mainData.value = _data;
  155. detailRef.value.refresh(_data);
  156. initParams.value.empid = Number(_data.empid);
  157. });
  158. return;
  159. }
  160. console.log("handleSelectItem _data :>> ", _data);
  161. mainData.value = _data;
  162. detailRef.value.refresh(_data);
  163. initParams.value.empid = Number(_data.empid);
  164. console.log("initParams.value :>> ", initParams.value);
  165. // if (!Boolean(Number(data.allow_view))) {
  166. // ElMessage.error("你没有权限查看");
  167. // return false;
  168. // }
  169. // console.log("handleSelectItem data :>> ", data);
  170. // initParams.value.classid = Number(data.classid);
  171. // checkAllowPower(data);
  172. };
  173. /*
  174. * @description 抽屉默认属性
  175. */
  176. const drawerDefineProp = {
  177. draggable: true,
  178. overflow: true,
  179. width: "40%"
  180. // modalClass: "lj-file-dialog"
  181. };
  182. const getData = async () => {
  183. userListLoading.value = true;
  184. let resSysfuncpwr = await getSysFuncPwr();
  185. sysFuncPwrData.value = resSysfuncpwr.list;
  186. let resDept = await getDept();
  187. deptData.value = resDept.list;
  188. let resPricelist = await getPriceList();
  189. priceListData.value = resPricelist.list;
  190. let res = await getUserList();
  191. console.log("pricelist res :>> ", res);
  192. userListData.value = res.userList;
  193. userListLoading.value = false;
  194. searchEvent();
  195. };
  196. onMounted(async () => {
  197. await getData();
  198. handleSelectItem(userListData.value[0]);
  199. });
  200. // const dataCallback = (data: any) => {
  201. // console.log("data :>> ", data);
  202. // return {
  203. // list: data.userList
  204. // // tableinfo: data.tableinfo,
  205. // // total: data.totalcnt,
  206. // // pageNum: data.pageindex,
  207. // // pageSize: data.pagesize
  208. // };
  209. // };
  210. const LjDialogRef = ref();
  211. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  212. // 弹窗
  213. // mainData.value = row;
  214. // headername.value = row.username;
  215. // orderStatus.value = "edit";
  216. // LjDialogRef.value.show();
  217. };
  218. // 返回绑定的事件
  219. const tableEvents = {
  220. // "cell-dblclick": handleDBlClickTable
  221. // "cell-click": handleClickTable
  222. };
  223. const handleAdd = () => {
  224. mainData.value = {
  225. empid: 0,
  226. userid: "",
  227. username: "",
  228. descrp: "",
  229. usermode: 0,
  230. rightstring: "",
  231. outrepstr: "",
  232. deptstr: "",
  233. pricelist_seestr: "",
  234. pricelist_editstr: ""
  235. };
  236. orderStatus.value = "new";
  237. detailRef.value.refresh(mainData.value);
  238. initParams.value.empid = -1;
  239. };
  240. const handleEdit = (data: any) => {
  241. if (data.empid == 0) {
  242. ElMessage.error("系统管理员账号,不能修改");
  243. return;
  244. }
  245. orderStatus.value = "edit";
  246. };
  247. const handleCancel = (data?: any) => {
  248. let _data = data ?? mainData.value;
  249. console.log("_data :>> ", _data, mainData.value);
  250. orderStatus.value = "";
  251. detailRef.value.refresh(_data);
  252. };
  253. const handleDel = (data: any) => {
  254. if (data.empid == 0) {
  255. ElMessage.error("系统管理员账号,不能删除");
  256. return;
  257. }
  258. ElMessageBox.confirm(t("business.detail.delConfirm") + data.username + " ?", t("sys.app.warning"), {
  259. confirmButtonText: t("common.delText"),
  260. cancelButtonText: t("common.cancelText"),
  261. type: "error"
  262. }).then(async () => {
  263. await delUserList({ useridList: [data.empid] });
  264. await getData();
  265. handleSelectItem(userListData.value[0]);
  266. });
  267. };
  268. const autoGotoUser = async (id: number) => {
  269. await getData();
  270. nextTick(() => {
  271. orderStatus.value = "";
  272. let item = userListData.value.find(t => t.empid == id);
  273. console.log("item :>> ", item);
  274. handleSelectItem(item);
  275. });
  276. };
  277. const searchProps = ["username", "userid"];
  278. // 节流
  279. const disshow = throttle((val: any) => {
  280. searchEvent();
  281. }, 500);
  282. const searchEvent = () => {
  283. const filterVal = String(searchInput.value).trim().toLowerCase();
  284. if (filterVal) {
  285. showUserList.value = pinyinFilterTree(filterVal, userListData.value, searchProps);
  286. } else {
  287. showUserList.value = userListData.value;
  288. }
  289. };
  290. const handleUnLock = (data: any) => {
  291. if (data.empid == 0) {
  292. ElMessage.error("系统管理员账号,不需要解锁");
  293. return;
  294. }
  295. ElMessageBox.confirm(`确认需要解锁用户:${data.username}?`, t("sys.app.warning"), {
  296. confirmButtonText: t("common.okText"),
  297. cancelButtonText: t("common.cancelText"),
  298. type: "error"
  299. }).then(async () => {
  300. await UnLockUser({ useridList: [data.empid] });
  301. await getData();
  302. handleSelectItem(userListData.value[0]);
  303. });
  304. };
  305. </script>
  306. <style lang="scss">
  307. .userlist {
  308. &__aside {
  309. background: $color-gray-1;
  310. padding: $space-b2 $space-b2;
  311. box-shadow: $shadow-0-down;
  312. border-radius: $br-md;
  313. &-searchbox {
  314. // padding: $space-b2 $space-b2;
  315. // margin-bottom: $space-b2;
  316. // background-color: $color-gray-3;
  317. // border-radius: $space-b1;
  318. margin-bottom: $space-b2;
  319. .el-form-item--default:last-child {
  320. margin-bottom: 0;
  321. }
  322. .el-input__wrapper {
  323. display: flex;
  324. }
  325. }
  326. &-header .el-affix--fixed {
  327. background: $color-gray-1;
  328. padding-top: 12px;
  329. // padding-bottom: $space-b2;
  330. }
  331. }
  332. }
  333. </style>