index.vue 4.4 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, msg, data } = await FIRSTDIRECT(prop);
  34. if (code === 200) {
  35. this.data = data;
  36. this.$notify.success({ title: msg });
  37. } else {
  38. this.hide();
  39. this.$notify.warning({ title: msg });
  40. }
  41. } catch (err) {
  42. this.hide();
  43. } finally {
  44. this.loading = false;
  45. }
  46. },
  47. //
  48. async submit() {
  49. const params = this.data
  50. .map((item) => ({
  51. ...item,
  52. orderPriceVos: item.orderPriceVos.filter(
  53. (citem) => citem.purchaseQuantity
  54. ),
  55. }))
  56. .filter((item) => item.orderPriceVos.length);
  57. try {
  58. const { code, msg } = await ADD(params);
  59. if (code === 200) {
  60. this.hide();
  61. this.$emit("success");
  62. this.$notify.success({ title: msg });
  63. } else {
  64. this.$notify.warning({ title: msg });
  65. }
  66. } catch (err) {
  67. //
  68. } finally {
  69. //
  70. }
  71. },
  72. },
  73. created() {},
  74. mounted() {},
  75. destroyed() {},
  76. };
  77. </script>
  78. <template>
  79. <el-dialog :visible.sync="visible" title="首次协议直采">
  80. <div
  81. v-for="(item, index) in data"
  82. :key="index"
  83. style="width: 100%; margin: 0 0 20px 0"
  84. >
  85. <el-descriptions border size="mini" :column="4">
  86. <template #title>
  87. <span style="margin-right: 10px">{{ item.materialName }}</span>
  88. <span style="color: tomato">{{ item.puQty }}</span>
  89. <span> {{ item.puUnitName }}</span>
  90. </template>
  91. <el-descriptions-item label="需求组织">
  92. {{ item.demandOrgName }}
  93. </el-descriptions-item>
  94. <el-descriptions-item label="采购组织">
  95. {{ item.puOrgName }}
  96. </el-descriptions-item>
  97. <el-descriptions-item label="需求时间">
  98. {{ item.demandDate }}
  99. </el-descriptions-item>
  100. </el-descriptions>
  101. <el-table
  102. v-loading="loading"
  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>