index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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
  106. :span="3"
  107. class="fr"
  108. style="width: 66px; padding: 0 0 0 10px"
  109. v-if="powers.some((item) => item == '003')"
  110. >
  111. <el-button
  112. :size="searchSize"
  113. type="success"
  114. style="float: right"
  115. @click="openModal({}, '003')"
  116. >
  117. 添加
  118. </el-button>
  119. </el-col>
  120. </el-row>
  121. </div></template
  122. >
  123. <template #status="{ scope }">
  124. <el-tag
  125. :size="tablebtnSize"
  126. :type="scope.row.status == '1' ? 'warning' : ''"
  127. v-text="
  128. (statusOptions.find((item) => item.id == scope.row.status) || {})
  129. .label || '--'
  130. "
  131. ></el-tag>
  132. </template>
  133. <template #operation="{ scope }">
  134. <el-tooltip
  135. v-if="powers.some((item) => item == '007')"
  136. effect="dark"
  137. content="详情"
  138. placement="top"
  139. >
  140. <i
  141. class="el-icon-view tb-icon"
  142. @click="openModal(scope.row, '007')"
  143. ></i>
  144. </el-tooltip>
  145. <el-tooltip
  146. v-if="powers.some((item) => item == '005')"
  147. effect="dark"
  148. content="修改"
  149. placement="top"
  150. >
  151. <i
  152. class="el-icon-edit tb-icon"
  153. @click="openModal(scope.row, '005')"
  154. ></i>
  155. </el-tooltip>
  156. <el-tooltip
  157. v-if="
  158. powers.some((item) => item == '004') && scope.row.status === '0'
  159. "
  160. effect="dark"
  161. content="禁用"
  162. placement="top"
  163. >
  164. <i
  165. class="el-icon-video-pause tb-icon"
  166. @click="changeStatus(scope.row.id, scope.row.status)"
  167. ></i>
  168. </el-tooltip>
  169. <el-tooltip
  170. v-if="
  171. powers.some((item) => item == '004') && scope.row.status === '1'
  172. "
  173. effect="dark"
  174. content="启用"
  175. placement="top"
  176. >
  177. <i
  178. class="el-icon-video-play tb-icon"
  179. @click="changeStatus(scope.row.id, scope.row.status)"
  180. ></i>
  181. </el-tooltip>
  182. <el-tooltip
  183. v-if="powers.some((item) => item == '006')"
  184. effect="dark"
  185. content="删除"
  186. placement="top"
  187. >
  188. <i
  189. class="el-icon-delete tb-icon"
  190. @click="deleteItem(scope.row.id)"
  191. ></i>
  192. </el-tooltip>
  193. </template>
  194. </ex-table>
  195. <no-auth v-else></no-auth>
  196. <!-- 弹窗 新增/修改 -->
  197. <add-edit
  198. :id="modelId"
  199. :show-model="showModel"
  200. :sitem="sitem"
  201. @refresh="searchList"
  202. @cancel="showModel = false"
  203. />
  204. </div>
  205. </template>
  206. <script>
  207. import asyncRequest from "@/apis/service/serviceParam/supplier";
  208. import statusList from "@/assets/js/statusList";
  209. import roleLevel from "@/assets/js/roleLevel";
  210. import mixinPage from "@/mixins/elPaginationHandle";
  211. import { mapGetters } from "vuex";
  212. import addEdit from "./addEdit";
  213. import resToken from "@/mixins/resToken";
  214. export default {
  215. name: "supplier",
  216. mixins: [mixinPage, resToken],
  217. components: {
  218. addEdit,
  219. },
  220. computed: {
  221. //组件SIZE设置
  222. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  223. powers() {
  224. let tran =
  225. this.$store.getters.btnList.find(
  226. (item) => item.menu_route == "supplier"
  227. ) || {};
  228. if (tran && tran.action && tran.action.length > 0) {
  229. return tran.action;
  230. } else {
  231. return [];
  232. }
  233. },
  234. },
  235. data() {
  236. return {
  237. statusList: statusList,
  238. roleLevel: roleLevel,
  239. loading: true,
  240. showModel: false,
  241. modelId: "000",
  242. sitem: {},
  243. parmValue: {
  244. page: 1, // 页码
  245. size: 15, // 每页显示条数
  246. start: "",
  247. end: "",
  248. status: "",
  249. creater: "",
  250. name:"",
  251. },
  252. // 状态
  253. statusOptions: [
  254. { id: "0", label: "禁用" },
  255. { id: "1", label: "启用" },
  256. ],
  257. // 表格 - 数据
  258. tableData: [],
  259. // 表格 - 参数
  260. table: {
  261. stripe: true,
  262. border: true,
  263. _defaultHeader_: ["setcol"],
  264. },
  265. // 表格 - 分页
  266. pageInfo: {
  267. size: 15,
  268. curr: 1,
  269. total: 0,
  270. },
  271. // 表格 - 列参数
  272. columns: [
  273. {
  274. prop: "code",
  275. label: "编号",
  276. width:"140"
  277. },
  278. {
  279. prop: "name",
  280. label: "供应商名称",
  281. },
  282. {
  283. prop: "status",
  284. label: "状态",
  285. width:"60",
  286. _slot_: "status",
  287. },
  288. {
  289. prop: "legaler",
  290. label: "法人",
  291. width:"80",
  292. },
  293. {
  294. prop: "creater",
  295. label: "创建人",
  296. },
  297. {
  298. prop: "addtime",
  299. label: "创建时间",
  300. width:"145",
  301. sortable: true,
  302. },
  303. {
  304. prop: "",
  305. label: "操作",
  306. fixed: "right",
  307. width:"140",
  308. _noset_: true,
  309. _slot_: "operation",
  310. },
  311. ],
  312. };
  313. },
  314. mounted() {
  315. this.searchList();
  316. },
  317. methods: {
  318. restSearch() {
  319. // 表格 - 分页
  320. this.pageInfo = {
  321. size: 15,
  322. curr: 1,
  323. total: 0,
  324. };
  325. this.parmValue = {
  326. page: 1, // 页码
  327. size: 15, // 每页显示条数
  328. start: "",
  329. end: "",
  330. status: "",
  331. creater: "",
  332. name:"",
  333. };
  334. this.searchList();
  335. },
  336. // 新建/编辑/详情
  337. openModal(row, type) {
  338. this.sitem = row;
  339. this.modelId = type;
  340. this.showModel = true;
  341. },
  342. // 时间
  343. async handleTime(e) {
  344. this.parmValue.start = e.startTime || "";
  345. this.parmValue.end = e.endTime || "";
  346. if (
  347. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  348. (this.parmValue.start === "" && this.parmValue.end === "")
  349. ) {
  350. this.pageInfo.curr = 1;
  351. this.parmValue.page = 1;
  352. await this.searchList();
  353. }
  354. },
  355. /**
  356. * 启用/禁用
  357. * @param {String} id id
  358. * @param {String} status 0-禁用 1-启用
  359. */
  360. async changeStatus(id, status) {
  361. await this.$confirm(`确定要改为${status === "0" ? "禁用" : "启用"}?`, {
  362. confirmButtonText: "确定",
  363. cancelButtonText: "取消",
  364. type: "warning",
  365. })
  366. .then(async () => {
  367. this.loading = true;
  368. const model = {
  369. id: id,
  370. status: status === "1" ? "0" : "1",
  371. };
  372. const res = await asyncRequest.status(model);
  373. if (res && res.code === 0) {
  374. this.loading = false;
  375. this.$notify.success({
  376. title: "状态修改成功!",
  377. message: "",
  378. });
  379. await this.searchList();
  380. } else if (res && res.code >= 100 && res.code <= 104) {
  381. await this.logout();
  382. } else {
  383. this.loading = false;
  384. this.$message.warning(res.message);
  385. }
  386. })
  387. .catch(() => {
  388. console.log("取消");
  389. });
  390. },
  391. async deleteItem(id) {
  392. await this.$confirm("确定要删除?", {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "warning",
  396. })
  397. .then(async () => {
  398. const model = {
  399. id: id,
  400. };
  401. const res = await asyncRequest.delete(model);
  402. if (res && res.code === 0) {
  403. this.$notify.success({
  404. title: "删除成功",
  405. message: "",
  406. });
  407. this.searchList();
  408. } else if (res && res.code >= 100 && res.code <= 104) {
  409. await this.logout();
  410. } else {
  411. this.$message.warning(res.message);
  412. }
  413. })
  414. .catch(() => {
  415. console.log("取消");
  416. });
  417. },
  418. // 刷新表格
  419. async searchList() {
  420. this.loading = true;
  421. const res = await asyncRequest.list(this.parmValue);
  422. if (res && res.code === 0 && res.data) {
  423. this.tableData = res.data.list;
  424. this.pageInfo.total = Number(res.data.count);
  425. } else if (res && res.code >= 100 && res.code <= 104) {
  426. await this.logout();
  427. } else {
  428. this.tableData = [];
  429. this.pageInfo.total = 0;
  430. }
  431. this.loading = false;
  432. },
  433. },
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. </style>