index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <script>
  2. import useColumns from "./columns";
  3. import {
  4. getDemandWindowList,
  5. saveDemandWindow,
  6. } from "@/api/purchase/purchaseDemand.js";
  7. export default {
  8. name: "Demand",
  9. props: {
  10. dict: {
  11. type: [Array, Object],
  12. default: () => [],
  13. },
  14. },
  15. components: {
  16. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  17. },
  18. data() {
  19. const { DemandColumns } = useColumns();
  20. return {
  21. title: "需求窗口期",
  22. visible: false,
  23. loading: false,
  24. DemandColumns: DemandColumns,
  25. innerValue: [],
  26. };
  27. },
  28. methods: {
  29. async open() {
  30. // 需求窗口期配置
  31. this.visible = true;
  32. try {
  33. this.loading = true;
  34. let { code, rows } = await getDemandWindowList();
  35. if (code === 200) {
  36. this.innerValue = rows;
  37. }
  38. } catch (error) {
  39. } finally {
  40. this.loading = false;
  41. }
  42. },
  43. close() {
  44. this.visible = false;
  45. this.innerValue = [];
  46. },
  47. async saveDemand() {
  48. try {
  49. let params = this.innerValue;
  50. let { code } = await saveDemandWindow(params);
  51. if (code === 200) {
  52. this.$modal.notifySuccess("保存成功");
  53. this.close();
  54. }
  55. } catch (error) {}
  56. },
  57. changeDeadline(row) {
  58. row.delFlag = "2";
  59. },
  60. },
  61. created() {},
  62. };
  63. </script>
  64. <template>
  65. <el-button type="primary" :size="$attrs.size" @click="open">
  66. {{ title }}
  67. <el-dialog
  68. :title="title"
  69. :visible.sync="visible"
  70. width="800px"
  71. append-to-body
  72. :close-on-click-modal="false"
  73. :close-on-press-escape="false"
  74. >
  75. <div slot="footer">
  76. <el-button :size="$attrs.size" @click="close">取 消</el-button>
  77. <el-button type="primary" :size="$attrs.size" @click="saveDemand"
  78. >保 存</el-button
  79. >
  80. </div>
  81. <el-super-ux-table
  82. v-loading="loading"
  83. v-model="innerValue"
  84. :columns="DemandColumns"
  85. :size="$attrs.size"
  86. :dict="dict"
  87. height="450"
  88. >
  89. <template slot="deadline" slot-scope="scope">
  90. <component
  91. v-bind="scope.attr"
  92. v-model="scope.row[scope.item.key]"
  93. :size="$attrs.size"
  94. :source.sync="scope.row"
  95. @input="changeDeadline(scope.row)"
  96. >
  97. </component>
  98. </template>
  99. </el-super-ux-table>
  100. <!-- <span style="color: red">注:周计划星期填写范围1-7,月计划填写范围1-12</span> -->
  101. </el-dialog>
  102. </el-button>
  103. </template>