index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <div class="supplier pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '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 80px">
  27. <el-col :span="6" style="width: 303px">
  28. <period-date-picker
  29. :type="1"
  30. :width="'135px'"
  31. :size="searchSize"
  32. :start="parmValue.start"
  33. :end="parmValue.end"
  34. @timeReturned="handleTime"
  35. />
  36. </el-col>
  37. <el-col :span="4" style="width: 160px">
  38. <el-select
  39. v-model="parmValue.status"
  40. filterable
  41. clearable
  42. :size="searchSize"
  43. placeholder="状态"
  44. style="width: 100%"
  45. @change="
  46. pageInfo.curr = 1;
  47. parmValue.page = 1;
  48. searchList();
  49. "
  50. >
  51. <el-option
  52. v-for="item in statusList"
  53. :key="'status' + item.code"
  54. :label="item.name"
  55. :value="item.code"
  56. />
  57. </el-select>
  58. </el-col>
  59. <el-col
  60. :span="3"
  61. class="fr"
  62. style="width: 66px; padding: 0 0 0 10px"
  63. >
  64. <el-button type="primary" :size="searchSize" @click="searchList">
  65. 刷新
  66. </el-button>
  67. </el-col>
  68. <el-col
  69. :span="3"
  70. class="fr"
  71. style="width: 66px; padding: 0 0 0 10px"
  72. >
  73. <el-button type="warning" :size="searchSize" @click="restSearch">
  74. 重置
  75. </el-button>
  76. </el-col>
  77. </el-row>
  78. <el-row>
  79. <el-col :span="4" style="width: 373px">
  80. <el-input
  81. :size="searchSize"
  82. v-model="parmValue.name"
  83. :maxlength="40"
  84. @blur="
  85. pageInfo.curr = 1;
  86. parmValue.page = 1;
  87. searchList();
  88. "
  89. placeholder="供应商名称"
  90. ></el-input>
  91. </el-col>
  92. <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
  93. <el-input
  94. :size="searchSize"
  95. v-model="parmValue.creater"
  96. :maxlength="40"
  97. @change="
  98. pageInfo.curr = 1;
  99. parmValue.page = 1;
  100. searchList();
  101. "
  102. placeholder="创建人"
  103. ></el-input>
  104. </el-col>
  105. <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
  106. <el-input
  107. :size="searchSize"
  108. v-model="parmValue.person"
  109. :maxlength="40"
  110. @change="
  111. pageInfo.curr = 1;
  112. parmValue.page = 1;
  113. searchList();
  114. "
  115. placeholder="负责人"
  116. ></el-input>
  117. </el-col>
  118. <el-col
  119. :span="3"
  120. class="fr"
  121. style="width: 66px; padding: 0 0 0 10px"
  122. v-if="powers.some((item) => item == '003')"
  123. >
  124. <el-button
  125. :size="searchSize"
  126. type="success"
  127. style="float: right"
  128. @click="routeGoto('supplierDetail', { id: 'add', type: 'add' })"
  129. >
  130. 添加
  131. </el-button>
  132. </el-col>
  133. </el-row>
  134. </div></template
  135. >
  136. <template #status="{ scope }">
  137. <el-tag
  138. :size="tablebtnSize"
  139. :type="scope.row.status == '0' ? 'warning' : ''"
  140. v-text="
  141. (statusOptions.find((item) => item.id == scope.row.status) || {})
  142. .label || '--'
  143. "
  144. ></el-tag>
  145. </template>
  146. <template #operation="{ scope }">
  147. <el-tooltip
  148. v-if="powers.some((item) => item == '007')"
  149. effect="dark"
  150. content="详情"
  151. placement="top"
  152. >
  153. <i
  154. class="el-icon-view tb-icon"
  155. @click="
  156. routeGoto('supplierDetail', {
  157. id: scope.row.id,
  158. type: 'view',
  159. })
  160. "
  161. ></i>
  162. </el-tooltip>
  163. <el-tooltip
  164. v-if="powers.some((item) => item == '005')"
  165. effect="dark"
  166. content="修改"
  167. placement="top"
  168. >
  169. <i
  170. class="el-icon-edit tb-icon"
  171. @click="gotoEdit(scope.row, '005')"
  172. ></i>
  173. </el-tooltip>
  174. <el-tooltip
  175. v-if="
  176. powers.some((item) => item == '004') && scope.row.status === '1'
  177. "
  178. effect="dark"
  179. content="禁用"
  180. placement="top"
  181. >
  182. <i
  183. class="el-icon-video-pause tb-icon"
  184. @click="changeStatus(scope.row.id, scope.row.status)"
  185. ></i>
  186. </el-tooltip>
  187. <el-tooltip
  188. v-if="
  189. powers.some((item) => item == '004') && scope.row.status === '0'
  190. "
  191. effect="dark"
  192. content="启用"
  193. placement="top"
  194. >
  195. <i
  196. class="el-icon-video-play tb-icon"
  197. @click="changeStatus(scope.row.id, scope.row.status)"
  198. ></i>
  199. </el-tooltip>
  200. <el-tooltip
  201. v-if="powers.some((item) => item == '006')"
  202. effect="dark"
  203. content="删除"
  204. placement="top"
  205. >
  206. <i
  207. class="el-icon-delete tb-icon"
  208. @click="deleteItem(scope.row.id)"
  209. ></i>
  210. </el-tooltip>
  211. <el-tooltip
  212. v-if="powers.some((item) => item == '006')"
  213. effect="dark"
  214. content="查看支持品牌"
  215. placement="top"
  216. >
  217. <i class="el-icon-search tb-icon" @click="openModal(scope.row)"></i>
  218. </el-tooltip>
  219. </template>
  220. </ex-table>
  221. <no-auth v-else></no-auth>
  222. <!-- 查看支持品牌 -->
  223. <show-brand-list
  224. :sitem="modelSitem"
  225. :show-model="showModel"
  226. @refresh="showModel = false"
  227. @cancel="showModel = false"
  228. />
  229. </div>
  230. </template>
  231. <script>
  232. import asyncRequest from "@/apis/service/serviceParam/supplier";
  233. import statusList from "@/assets/js/statusList";
  234. import roleLevel from "@/assets/js/roleLevel";
  235. import mixinPage from "@/mixins/elPaginationHandle";
  236. import { mapGetters } from "vuex";
  237. import showBrandList from "./components/show-brand-list";
  238. import resToken from "@/mixins/resToken";
  239. export default {
  240. name: "supplier",
  241. mixins: [mixinPage, resToken],
  242. components: {
  243. showBrandList,
  244. },
  245. computed: {
  246. //组件SIZE设置
  247. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  248. powers() {
  249. let tran =
  250. this.$store.getters.btnList.find(
  251. (item) => item.menu_route == "supplier"
  252. ) || {};
  253. if (tran && tran.action && tran.action.length > 0) {
  254. return tran.action;
  255. } else {
  256. return [];
  257. }
  258. },
  259. },
  260. data() {
  261. return {
  262. statusList: statusList,
  263. roleLevel: roleLevel,
  264. loading: true,
  265. showModel: false,
  266. modelSitem: null,
  267. stype: {},
  268. parmValue: {
  269. page: 1, // 页码
  270. size: 15, // 每页显示条数
  271. start: "",
  272. end: "",
  273. status: "",
  274. creater: "",
  275. name: "",
  276. },
  277. // 状态
  278. statusOptions: [
  279. { id: "0", label: "禁用" },
  280. { id: "1", label: "启用" },
  281. ],
  282. // 表格 - 数据
  283. tableData: [],
  284. // 表格 - 参数
  285. table: {
  286. stripe: true,
  287. border: true,
  288. _defaultHeader_: ["setcol"],
  289. },
  290. // 表格 - 分页
  291. pageInfo: {
  292. size: 15,
  293. curr: 1,
  294. total: 0,
  295. },
  296. // 表格 - 列参数
  297. columns: [
  298. {
  299. prop: "code",
  300. label: "编号",
  301. width: "140",
  302. },
  303. {
  304. prop: "name",
  305. label: "供应商名称",
  306. },
  307. {
  308. prop: "status",
  309. label: "状态",
  310. width: "60",
  311. _slot_: "status",
  312. },
  313. {
  314. prop: "legaler",
  315. label: "法人",
  316. width: "80",
  317. },
  318. {
  319. prop: "person",
  320. label: "负责人",
  321. width: "100",
  322. },
  323. {
  324. prop: "creater",
  325. label: "创建人",
  326. width: "100",
  327. },
  328. {
  329. prop: "addtime",
  330. label: "创建时间",
  331. width: "145",
  332. sortable: true,
  333. },
  334. {
  335. prop: "",
  336. label: "操作",
  337. fixed: "right",
  338. width: "180",
  339. _noset_: true,
  340. _slot_: "operation",
  341. },
  342. ],
  343. };
  344. },
  345. mounted() {
  346. this.searchList();
  347. },
  348. methods: {
  349. restSearch() {
  350. // 表格 - 分页
  351. this.pageInfo = {
  352. size: 15,
  353. curr: 1,
  354. total: 0,
  355. };
  356. this.parmValue = {
  357. page: 1, // 页码
  358. size: 15, // 每页显示条数
  359. start: "",
  360. end: "",
  361. status: "",
  362. creater: "",
  363. name: "",
  364. person: "",
  365. };
  366. this.searchList();
  367. },
  368. // 新建/编辑/详情
  369. openModal(sitem) {
  370. this.modelSitem = sitem;
  371. this.showModel = true;
  372. },
  373. // 时间
  374. async handleTime(e) {
  375. this.parmValue.start = e.startTime || "";
  376. this.parmValue.end = e.endTime || "";
  377. if (
  378. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  379. (this.parmValue.start === "" && this.parmValue.end === "")
  380. ) {
  381. this.pageInfo.curr = 1;
  382. this.parmValue.page = 1;
  383. await this.searchList();
  384. }
  385. },
  386. gotoEdit(row, type) {
  387. const { status } = row;
  388. if (type === "005" && status === "1") {
  389. this.$message.warning("禁用后,才可以修改!");
  390. return;
  391. }
  392. this.routeGoto("supplierDetail", {
  393. id: row.id,
  394. type: "edit",
  395. });
  396. },
  397. /**
  398. * 启用/禁用
  399. * @param {String} id id
  400. * @param {String} status 0-禁用 1-启用
  401. */
  402. async changeStatus(id, status) {
  403. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  404. confirmButtonText: "确定",
  405. cancelButtonText: "取消",
  406. type: "warning",
  407. })
  408. .then(async () => {
  409. this.loading = true;
  410. const model = {
  411. id: id,
  412. status: status === "1" ? "0" : "1",
  413. };
  414. const res = await asyncRequest.status(model);
  415. if (res && res.code === 0) {
  416. this.loading = false;
  417. this.$notify.success({
  418. title: "状态修改成功!",
  419. message: "",
  420. });
  421. await this.searchList();
  422. } else if (res && res.code >= 100 && res.code <= 104) {
  423. await this.logout();
  424. } else {
  425. this.loading = false;
  426. this.$message.warning(res.message);
  427. }
  428. })
  429. .catch(() => {
  430. console.log("取消");
  431. });
  432. },
  433. async deleteItem(id) {
  434. await this.$confirm("确定要删除?", {
  435. confirmButtonText: "确定",
  436. cancelButtonText: "取消",
  437. type: "warning",
  438. })
  439. .then(async () => {
  440. const model = {
  441. id: id,
  442. };
  443. const res = await asyncRequest.delete(model);
  444. if (res && res.code === 0) {
  445. this.$notify.success({
  446. title: "删除成功",
  447. message: "",
  448. });
  449. this.searchList();
  450. } else if (res && res.code >= 100 && res.code <= 104) {
  451. await this.logout();
  452. } else {
  453. this.$message.warning(res.message);
  454. }
  455. })
  456. .catch(() => {
  457. console.log("取消");
  458. });
  459. },
  460. // 刷新表格
  461. async searchList() {
  462. this.loading = true;
  463. const { code, data, message } = await asyncRequest.list(this.parmValue);
  464. let scode = parseInt(code + "");
  465. if (scode === 0) {
  466. const { list, count } = data;
  467. this.tableData = list;
  468. this.pageInfo.total = Number(count + "");
  469. } else if (scode >= 100 && scode <= 104) {
  470. await this.logout();
  471. } else {
  472. this.tableData = [];
  473. this.pageInfo.total = 0;
  474. }
  475. this.loading = false;
  476. },
  477. },
  478. };
  479. </script>
  480. <style lang="scss" scoped>
  481. </style>