index.vue 12 KB

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