index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <div class="sort pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers.some((i) => i == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 10px 90px">
  27. <el-col :span="3" style="width: 748px">
  28. <div class="my-breadcrumb clear">
  29. <div
  30. class="my-breadcrumb-item"
  31. v-for="(item, index) in titleList"
  32. :key="item + index"
  33. @click="changeBreadcrumb(index)"
  34. >
  35. <span class="label">{{ item.titleName }}</span
  36. ><span class="separator" v-if="index + 1 !== titleList.length">/</span>
  37. </div>
  38. </div>
  39. </el-col>
  40. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  41. <el-button type="primary" :size="searchSize" @click="searchList">
  42. 刷新
  43. </el-button>
  44. </el-col>
  45. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  46. <el-button type="warning" :size="searchSize" @click="restSearch">
  47. 重置
  48. </el-button>
  49. </el-col>
  50. </el-row>
  51. <el-row>
  52. <el-col :span="4" style="width: 140px">
  53. <el-select
  54. v-model="parmValue.status"
  55. filterable
  56. clearable
  57. :size="searchSize"
  58. placeholder="分类状态"
  59. style="width: 100%"
  60. @change="
  61. pageInfo.curr = 1;
  62. parmValue.page = 1;
  63. searchList();
  64. "
  65. >
  66. <el-option
  67. v-for="item in statusList"
  68. :key="'status' + item.code"
  69. :label="item.name"
  70. :value="item.code"
  71. />
  72. </el-select>
  73. </el-col>
  74. <el-col :span="4" style="width: 390px; padding: 0 0 0 10px">
  75. <search-terrace
  76. :value="parmValue.platform_id"
  77. :disabled="false"
  78. :size="'mini'"
  79. :isDetail="false"
  80. :is_show="'0'"
  81. :placeholder="'平台名称'"
  82. @searchChange="platform_codeChange"
  83. />
  84. </el-col>
  85. <el-col :span="4" style="width: 390px; padding: 0 0 0 10px">
  86. <el-input
  87. :size="searchSize"
  88. v-model="parmValue.cat_name"
  89. :maxlength="40"
  90. @blur="
  91. pageInfo.curr = 1;
  92. parmValue.page = 1;
  93. searchList();
  94. "
  95. placeholder="分类名称"
  96. ></el-input>
  97. </el-col>
  98. </el-row></div
  99. ></template>
  100. <template #companyNo>
  101. <div>{{ getCompanyWithCode(currentCompany).code }}</div>
  102. </template>
  103. <template #companyName>
  104. <div>{{ getCompanyWithCode(currentCompany).name }}</div>
  105. </template>
  106. <template #status="{ scope }">
  107. <el-tag
  108. :size="tablebtnSize"
  109. :type="scope.row.status == '1' ? '' : 'warning'"
  110. v-text="
  111. (statusOptions.find((item) => item.id == scope.row.status) || {}).label ||
  112. '禁用'
  113. "
  114. ></el-tag>
  115. </template>
  116. <template #order_rate="{ scope }">
  117. <div>
  118. {{
  119. private_field &&
  120. private_field.length > 0 &&
  121. private_field.some((item) => item == "3")
  122. ? scope.row.order_rate
  123. : "****"
  124. }}
  125. </div>
  126. </template>
  127. <template #sale_rate="{ scope }">
  128. <div>
  129. {{
  130. private_field &&
  131. private_field.length > 0 &&
  132. private_field.some((item) => item == "3")
  133. ? scope.row.sale_rate
  134. : "****"
  135. }}
  136. </div>
  137. </template>
  138. <template #rate="{ scope }">
  139. <div>
  140. {{
  141. private_field &&
  142. private_field.length > 0 &&
  143. private_field.some((item) => item == "3")
  144. ? scope.row.rate
  145. : "****"
  146. }}
  147. </div>
  148. </template>
  149. <template #money_rate="{ scope }">
  150. <div>
  151. {{
  152. private_field &&
  153. private_field.length > 0 &&
  154. private_field.some((item) => item == "3")
  155. ? scope.row.money_rate
  156. : "****"
  157. }}
  158. </div>
  159. </template>
  160. <template #low_rate="{ scope }">
  161. <div>
  162. {{
  163. private_field &&
  164. private_field.length > 0 &&
  165. private_field.some((item) => item == "3")
  166. ? scope.row.low_rate
  167. : "****"
  168. }}
  169. </div>
  170. </template>
  171. <template #operation="{ scope }">
  172. <el-tooltip
  173. v-if="powers.some((i) => i == '007')"
  174. effect="dark"
  175. content="查看"
  176. placement="top"
  177. >
  178. <i class="el-icon-view tb-icon" @click="setRate(scope.row, true)"></i>
  179. </el-tooltip>
  180. <el-tooltip
  181. v-if="powers.some((i) => i == '005')"
  182. effect="dark"
  183. content="修改"
  184. placement="top"
  185. >
  186. <i class="el-icon-edit tb-icon" @click="setRate(scope.row)"></i>
  187. </el-tooltip>
  188. <!-- <el-tooltip
  189. v-if="powers.some((i) => i == '004') && scope.row.status + '' === '1'"
  190. effect="dark"
  191. content="禁用"
  192. placement="top"
  193. >
  194. <i
  195. class="el-icon-video-pause tb-icon"
  196. @click="changeStatus(scope.row.cat_id, scope.row.status)"
  197. ></i>
  198. </el-tooltip>
  199. <el-tooltip
  200. v-if="powers.some((i) => i == '004') && scope.row.status + '' !== '1'"
  201. effect="dark"
  202. content="启用"
  203. placement="top"
  204. >
  205. <i
  206. class="el-icon-video-play tb-icon"
  207. @click="changeStatus(scope.row.cat_id, scope.row.status)"
  208. ></i>
  209. </el-tooltip> -->
  210. <el-tooltip
  211. v-if="parseInt(scope.row.level) < 3"
  212. effect="dark"
  213. content="下级分类"
  214. placement="top"
  215. >
  216. <i class="el-icon-arrow-right tb-icon" @click="openChildren(scope.row)"></i>
  217. </el-tooltip>
  218. </template>
  219. </ex-table>
  220. <no-auth v-else></no-auth>
  221. <!-- 弹窗 新增/修改 -->
  222. <add-edit-rate
  223. :id="modelRateId"
  224. :show-model="showRateModel"
  225. :sitem="sitemRate"
  226. :titleList="titleList"
  227. @refresh="searchList"
  228. @cancel="showRateModel = false"
  229. :is-detail="isDetail"
  230. :platform_id="parmValue.platform_id"
  231. />
  232. </div>
  233. </template>
  234. <script>
  235. import addEditRate from "./addEditRate";
  236. import asyncRequest from "@/apis/service/serviceParam/platformGrossProfit";
  237. import { statusList } from "@/assets/js/statusList";
  238. import roleLevel from "@/assets/js/roleLevel";
  239. import mixinPage from "@/mixins/elPaginationHandle";
  240. import companyHelper from "@/mixins/companyHelper";
  241. import resToken from "@/mixins/resToken";
  242. import { mapGetters } from "vuex";
  243. export default {
  244. name: "othsearchSort",
  245. mixins: [mixinPage, resToken, companyHelper],
  246. components: {
  247. addEditRate,
  248. },
  249. computed: {
  250. //组件SIZE设置
  251. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  252. powers() {
  253. const { btnList } = this.$store.getters;
  254. const tran = btnList.find((i) => i.menu_route == "platformGrossProfit") || {};
  255. const { action } = tran ?? {};
  256. return action ?? [];
  257. },
  258. },
  259. data() {
  260. return {
  261. isDetail: true,
  262. private_field: [],
  263. statusList: statusList,
  264. roleLevel: roleLevel,
  265. loading: false,
  266. sitem: {},
  267. showRateModel: false,
  268. modelRateId: "000",
  269. sitemRate: {},
  270. titleList: [],
  271. parmValue: {
  272. page: 1, // 页码
  273. size: 15, // 每页显示条数
  274. status: "",
  275. platform_id: "",
  276. cat_name: "",
  277. pid: "0",
  278. },
  279. // 状态
  280. statusOptions: [
  281. { id: "0", label: "禁用" },
  282. { id: "1", label: "启用" },
  283. ],
  284. // 表格 - 数据
  285. tableData: [],
  286. // 表格 - 参数
  287. table: {
  288. stripe: true,
  289. border: true,
  290. _defaultHeader_: ["setcol"],
  291. },
  292. // 表格 - 分页
  293. pageInfo: {
  294. size: 15,
  295. curr: 1,
  296. total: 0,
  297. },
  298. // 表格 - 列参数
  299. columns: [
  300. // {
  301. // prop: "id",
  302. // label: "ID",
  303. // "min-width": "100px",
  304. // },
  305. {
  306. prop: "cat_name",
  307. label: "分类名称",
  308. minWidth: "130px",
  309. },
  310. {
  311. prop: "level",
  312. label: "分类等级",
  313. width: "80px",
  314. },
  315. {
  316. prop: "status",
  317. label: "状态",
  318. _slot_: "status",
  319. width: "70px",
  320. },
  321. // {
  322. // prop: "platform_name",
  323. // label: "平台名称",
  324. // minwidth: "190px",
  325. // },
  326. {
  327. prop: "companyNo",
  328. label: "公司编号",
  329. _slot_: "companyNo",
  330. width: "260px",
  331. },
  332. {
  333. prop: "companyName",
  334. label: "公司名称",
  335. _slot_: "companyName",
  336. width: "260px",
  337. },
  338. // {
  339. // prop: "fund_code",
  340. // label: "财务核算码",
  341. // width: "150px",
  342. // },
  343. // {
  344. // prop: "sale_rate",
  345. // label: "成本→售价",
  346. // _slot_: "sale_rate",
  347. // width: "90px",
  348. // },
  349. {
  350. prop: "",
  351. label: "操作",
  352. fixed: "right",
  353. width: "140px",
  354. _noset_: true,
  355. _slot_: "operation",
  356. },
  357. ],
  358. };
  359. },
  360. mounted() {
  361. this.initTitleList();
  362. this.parmValue.pid = "0";
  363. this.searchList();
  364. },
  365. methods: {
  366. restSearch() {
  367. // 表格 - 分页
  368. this.pageInfo = {
  369. size: 15,
  370. curr: 1,
  371. total: 0,
  372. };
  373. this.parmValue = {
  374. page: 1, // 页码
  375. size: 15, // 每页显示条数
  376. status: "",
  377. cat_name: "",
  378. platform_id: "",
  379. pid: "0",
  380. };
  381. this.initTitleList();
  382. this.searchList();
  383. },
  384. async platform_codeChange(e) {
  385. const { id } = e;
  386. this.parmValue.platform_id = id || "";
  387. this.pageInfo.curr = 1;
  388. this.parmValue.page = 1;
  389. await this.searchList();
  390. },
  391. initTitleList() {
  392. this.titleList = [];
  393. let model = { id: "0", titleName: "全部一级分类" };
  394. this.titleList.push(model);
  395. },
  396. //查看下一级分类
  397. async openChildren(item) {
  398. this.parmValue.pid = item.cat_id;
  399. this.pageInfo.curr = 1;
  400. this.parmValue.page = 1;
  401. await this.searchList();
  402. let model = {
  403. id: item.id,
  404. titleName: item.cat_name,
  405. };
  406. this.titleList.push(model);
  407. },
  408. //设置毛利率
  409. setRate(row, isDetail = false) {
  410. this.isDetail = isDetail;
  411. this.modelRateId = row.id;
  412. this.sitemRate = row;
  413. this.showRateModel = true;
  414. },
  415. async changeBreadcrumb(index) {
  416. if (index + 1 === this.titleList.length) {
  417. return;
  418. } else {
  419. this.parmValue.pid = this.titleList[index].id;
  420. this.titleList = this.titleList.slice(0, index + 1);
  421. }
  422. // if (this.titleList.length === 1) {
  423. // this.titleList = [];
  424. // }
  425. this.parmValue.cat_name = "";
  426. this.pageInfo.curr = 1;
  427. this.parmValue.page = 1;
  428. await this.searchList();
  429. },
  430. async changeStatus(cat_id, status) {
  431. await this.$confirm(`确定要改为${status + "" === "1" ? "禁用" : "启用"}?`, {
  432. confirmButtonText: "确定",
  433. cancelButtonText: "取消",
  434. type: "warning",
  435. })
  436. .then(async () => {
  437. this.loading = true;
  438. const model = {
  439. cat_id,
  440. platform_id: this.parmValue.platform_id,
  441. status: String(status) ? (String(status) === "1" ? "0" : "1") : "1",
  442. companyNo: this.currentCompany,
  443. };
  444. const res = await asyncRequest.status(model);
  445. if (res && res.code === 0) {
  446. this.loading = false;
  447. this.$notify.success({
  448. title: "状态修改成功!",
  449. message: "",
  450. });
  451. await this.searchList();
  452. } else if (res && res.code >= 100 && res.code <= 104) {
  453. await this.logout();
  454. } else {
  455. this.loading = false;
  456. this.$message.warning(res.message);
  457. }
  458. })
  459. .catch(() => {
  460. console.log("取消");
  461. });
  462. },
  463. // 刷新表格
  464. async searchList() {
  465. if (this.loading) return;
  466. if (!this.currentCompany) {
  467. this.$message.warning("请选择公司!");
  468. return;
  469. }
  470. if (this.parmValue.platform_id === "") {
  471. this.$message.warning("请选择平台!");
  472. return;
  473. }
  474. this.parmValue.companyNo = this.currentCompany;
  475. this.loading = true;
  476. const { code, data } = await asyncRequest.list(this.parmValue);
  477. if (code === 0) {
  478. const { list, count } = data ?? {};
  479. this.tableData = list ?? [];
  480. this.pageInfo.total = count ?? 0;
  481. } else if (code >= 100 && code <= 104) {
  482. await this.logout();
  483. } else {
  484. this.tableData = [];
  485. this.pageInfo.total = 0;
  486. }
  487. this.loading = false;
  488. },
  489. },
  490. };
  491. </script>
  492. <style lang="scss" scoped>
  493. .sort {
  494. .my-breadcrumb {
  495. .my-breadcrumb-item {
  496. float: left;
  497. span {
  498. height: 32px;
  499. line-height: 32px;
  500. }
  501. .label {
  502. padding: 0 5px 0 0;
  503. color: 010101;
  504. }
  505. .separator {
  506. color: #787878;
  507. font-size: 13px;
  508. padding: 0 5px 0 0;
  509. }
  510. &:last-child {
  511. .label {
  512. color: #787878;
  513. }
  514. }
  515. &:hover {
  516. cursor: pointer;
  517. }
  518. &:last-child {
  519. cursor: default;
  520. }
  521. &:only-child {
  522. cursor: pointer;
  523. }
  524. }
  525. }
  526. }
  527. </style>