index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. import companyHelper from "@/mixins/companyHelper"
  228. export default {
  229. name: "orderuse",
  230. mixins: [mixinPage, resToken, companyHelper],
  231. components: {
  232. addEdit,
  233. },
  234. computed: {
  235. //组件SIZE设置
  236. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  237. powers() {
  238. const tran =
  239. this.$store.getters.btnList.find(
  240. (item) => item.menu_route == "orderuse"
  241. ) || {};
  242. const { action } = tran ?? {};
  243. return action ?? [];
  244. },
  245. },
  246. data() {
  247. return {
  248. statusList: statusList,
  249. roleLevel: roleLevel,
  250. loading: true,
  251. showModel: false,
  252. modelId: "000",
  253. sitem: {},
  254. parmValue: {
  255. page: 1, // 页码
  256. size: 15, // 每页显示条数
  257. start: "",
  258. end: "",
  259. order_use:"",
  260. status: "",
  261. company_name: "", //创建人部门
  262. creater: "",
  263. },
  264. // 状态
  265. statusOptions: [
  266. { id: "0", label: "禁用" },
  267. { id: "1", label: "启用" },
  268. ],
  269. // 表格 - 数据
  270. tableData: [],
  271. // 表格 - 参数
  272. table: {
  273. stripe: true,
  274. border: true,
  275. _defaultHeader_: ["setcol"],
  276. },
  277. // 表格 - 分页
  278. pageInfo: {
  279. size: 15,
  280. curr: 1,
  281. total: 0,
  282. },
  283. // 表格 - 列参数
  284. columns: [
  285. {
  286. prop: "id",
  287. label: "ID",
  288. width:"80px"
  289. },
  290. {
  291. prop: "order_use",
  292. label: "订单用途名称",
  293. },
  294. {
  295. prop: "status",
  296. label: "状态",
  297. // sortable: true,
  298. _slot_: "status",
  299. },
  300. {
  301. prop: "creater",
  302. label: "创建人",
  303. },
  304. {
  305. prop: "companyNo",
  306. label: "公司编码",
  307. minWidth: "150px",
  308. },
  309. {
  310. prop: "companyName",
  311. label: "公司名称",
  312. minWidth: "150px",
  313. },
  314. {
  315. prop: "addtime",
  316. label: "创建时间",
  317. // sortable: true,
  318. },
  319. {
  320. prop: "",
  321. label: "操作",
  322. fixed: "right",
  323. _noset_: true,
  324. minWidth: "90px",
  325. _slot_: "operation",
  326. },
  327. ],
  328. };
  329. },
  330. mounted() {
  331. this.searchList();
  332. },
  333. methods: {
  334. restSearch() {
  335. // 表格 - 分页
  336. this.pageInfo = {
  337. size: 15,
  338. curr: 1,
  339. total: 0,
  340. };
  341. this.parmValue = {
  342. page: 1, // 页码
  343. size: 15, // 每页显示条数
  344. start: "",
  345. end: "",
  346. order_use:"",
  347. status: "",
  348. company_name: "", //创建人部门
  349. creater: "",
  350. };
  351. this.searchList();
  352. },
  353. // 新建/编辑/详情
  354. openModal(row, type) {
  355. const {status}=row
  356. if (type === "005" && status + '' === "1") {
  357. this.$message.warning("禁用后,才可以修改!");
  358. return;
  359. }
  360. this.sitem = row;
  361. this.modelId = type;
  362. this.showModel = true;
  363. },
  364. // 时间
  365. async handleTime(e) {
  366. this.parmValue.start = e.startTime || "";
  367. this.parmValue.end = e.endTime || "";
  368. if (
  369. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  370. (this.parmValue.start === "" && this.parmValue.end === "")
  371. ) {
  372. this.pageInfo.curr = 1;
  373. this.parmValue.page = 1;
  374. await this.searchList();
  375. }
  376. },
  377. /**
  378. * 启用/禁用
  379. * @param {String} id id
  380. * @param {String} status 0-禁用 1-启用
  381. */
  382. async changeStatus(id, status) {
  383. await this.$confirm(`确定要改为${status + '' === "1" ? "禁用" : "启用"}?`, {
  384. confirmButtonText: "确定",
  385. cancelButtonText: "取消",
  386. type: "warning",
  387. })
  388. .then(async () => {
  389. this.loading = true;
  390. const model = {
  391. id: id,
  392. status: status + '' === "1" ? "0" : "1",
  393. };
  394. const res = await asyncRequest.status({
  395. ...model,
  396. needRela: true
  397. });
  398. if (res && res.code === 0) {
  399. this.loading = false;
  400. this.$notify.success({
  401. title: "状态修改成功!",
  402. message: "",
  403. });
  404. await this.searchList();
  405. } else if (res && res.code >= 100 && res.code <= 104) {
  406. await this.logout();
  407. } else {
  408. this.loading = false;
  409. this.$message.warning(res.message);
  410. }
  411. })
  412. .catch(() => {
  413. console.log("取消");
  414. });
  415. },
  416. async deleteItem(id) {
  417. await this.$confirm("确定要删除?", {
  418. confirmButtonText: "确定",
  419. cancelButtonText: "取消",
  420. type: "warning",
  421. })
  422. .then(async () => {
  423. const model = {
  424. id: id,
  425. };
  426. const res = await asyncRequest.delete(model);
  427. if (res && res.code === 0) {
  428. this.$notify.success({
  429. title: "删除成功",
  430. message: "",
  431. });
  432. this.searchList();
  433. } else if (res && res.code >= 100 && res.code <= 104) {
  434. await this.logout();
  435. } else {
  436. this.$message.warning(res.message);
  437. }
  438. })
  439. .catch(() => {
  440. console.log("取消");
  441. });
  442. },
  443. // 刷新表格
  444. async searchList() {
  445. if (
  446. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  447. (this.parmValue.start == "" && this.parmValue.end != "")
  448. ) {
  449. this.$message.warning("开始时间和结束时间不能为空");
  450. return;
  451. }
  452. this.loading = true;
  453. const res = await asyncRequest.list({
  454. ...this.parmValue,
  455. needRela: true
  456. });
  457. if (res && res.code === 0 && res.data) {
  458. this.tableData = res.data.list;
  459. this.pageInfo.total = Number(res.data.count);
  460. } else if (res && res.code >= 100 && res.code <= 104) {
  461. await this.logout();
  462. } else {
  463. this.tableData = [];
  464. this.pageInfo.total = 0;
  465. }
  466. this.loading = false;
  467. },
  468. },
  469. };
  470. </script>
  471. <style lang="scss" scoped>
  472. </style>