index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <script>
  2. import { TableColumns } from "./column";
  3. import { initColumns } from "@/utils/init";
  4. import { FIRSTDIRECT, ADD } from "@/api/business/purchase/task";
  5. export default {
  6. name: "FirstDirectPurchaseDialog",
  7. components: {},
  8. data() {
  9. return {
  10. size: "mini",
  11. visible: false,
  12. loading: false,
  13. tableColumns: initColumns(TableColumns),
  14. data: [],
  15. };
  16. },
  17. computed: {},
  18. watch: {},
  19. methods: {
  20. //
  21. open(prop) {
  22. this.visible = true;
  23. this.fetchItem(prop);
  24. },
  25. //
  26. hide() {
  27. this.visible = false;
  28. },
  29. //
  30. async fetchItem(prop) {
  31. try {
  32. this.loading = true;
  33. const { code, data } = await FIRSTDIRECT(prop);
  34. if (code === 200) {
  35. this.data = data;
  36. } else {
  37. this.hide();
  38. this.$notify.warning({ title: msg });
  39. }
  40. } catch (err) {
  41. this.hide();
  42. } finally {
  43. this.loading = false;
  44. }
  45. },
  46. //
  47. async submit() {
  48. const params = this.data
  49. .map((item) => ({
  50. ...item,
  51. orderPriceVos: item.orderPriceVos.filter(
  52. (citem) => citem.purchaseQuantity
  53. ),
  54. }))
  55. .filter((item) => item.orderPriceVos.length);
  56. try {
  57. const { code, msg } = await ADD(params);
  58. if (code === 200) {
  59. this.hide();
  60. this.$emit("success");
  61. this.$notify.success({ title: msg, duration: 0 });
  62. } else {
  63. this.$notify.warning({ title: msg });
  64. }
  65. } catch (err) {
  66. //
  67. } finally {
  68. //
  69. }
  70. },
  71. },
  72. created() {},
  73. mounted() {},
  74. destroyed() {},
  75. };
  76. </script>
  77. <template>
  78. <el-dialog :visible.sync="visible" width="75%" title="首次协议直采">
  79. <div
  80. v-for="(item, index) in data"
  81. :key="index"
  82. style="width: 100%; margin: 0 0 20px 0"
  83. >
  84. <el-descriptions border size="mini" :column="4">
  85. <template #title>
  86. <span style="margin-right: 10px">{{ item.materialName }}</span>
  87. <span style="color: tomato">{{ item.puQty }}</span>
  88. <span> {{ item.puUnitName }}</span>
  89. </template>
  90. <el-descriptions-item label="需求组织">
  91. {{ item.demandOrgName }}
  92. </el-descriptions-item>
  93. <el-descriptions-item label="采购组织">
  94. {{ item.puOrgName }}
  95. </el-descriptions-item>
  96. <el-descriptions-item label="需求时间">
  97. {{ item.demandDate }}
  98. </el-descriptions-item>
  99. </el-descriptions>
  100. <el-table
  101. v-loading="loading"
  102. :size="size"
  103. :data="item.orderPriceVos"
  104. style="width: 100%"
  105. >
  106. <el-table-column
  107. v-for="(cItem, cIndex) in tableColumns"
  108. :key="cIndex"
  109. :prop="cItem.key"
  110. :label="cItem.title"
  111. :fixed="cItem.fixed"
  112. :width="cItem.width || 180"
  113. show-overflow-tooltip
  114. >
  115. <template slot-scope="scope">
  116. <el-input-number
  117. v-if="cItem.inputType === 'InputNumber'"
  118. v-model="scope.row[cItem.key]"
  119. :size="size"
  120. :min="cItem.min(item)"
  121. :max="cItem.max(item)"
  122. :controls-position="cItem.controlsPosition"
  123. :placeholder="cItem.placeholder"
  124. style="width: 90%"
  125. ></el-input-number>
  126. <el-date-picker
  127. v-else-if="cItem.inputType === 'DatePicker'"
  128. v-model="scope.row[cItem.key]"
  129. :size="size"
  130. :type="cItem.type"
  131. :placeholder="cItem.placeholder"
  132. :picker-options="cItem.pickerOptions"
  133. :value-format="cItem.valueFormat"
  134. style="width: 90%"
  135. ></el-date-picker>
  136. <el-input
  137. v-else-if="cItem.inputType === 'Textarea'"
  138. v-model="scope.row[cItem.key]"
  139. :size="size"
  140. autosize
  141. type="textarea"
  142. style="width: 90%"
  143. ></el-input>
  144. <span v-else>{{ scope.row[cItem.key] }}</span>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <div slot="footer" style="text-align: right; margin-top: 10px">
  149. <el-button :size="size" @click="hide">取 消</el-button>
  150. <el-button :size="size" @click="submit">提 交</el-button>
  151. </div>
  152. </div>
  153. </el-dialog>
  154. </template>
  155. <style scoped></style>