index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <script>
  2. import { TableColumns } from "./column";
  3. import { FIRSTDIRECT, ADD } from "@/api/business/purchase/task";
  4. import { initColumns } from "@/utils/init";
  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.$notify.warning({ title: msg });
  39. }
  40. } catch (err) {
  41. //
  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.$notify.success({ title: msg });
  61. } else {
  62. this.$notify.warning({ title: msg });
  63. }
  64. } catch (err) {
  65. //
  66. } finally {
  67. //
  68. }
  69. },
  70. },
  71. created() {},
  72. mounted() {},
  73. destroyed() {},
  74. };
  75. </script>
  76. <template>
  77. <el-dialog :visible.sync="visible" title="首次协议直采">
  78. <div
  79. v-for="(item, index) in data"
  80. :key="index"
  81. style="width: 100%; margin: 0 0 20px 0"
  82. >
  83. <el-descriptions border size="mini" :column="4">
  84. <template #title>
  85. <span style="margin-right: 10px">{{ item.materialName }}</span>
  86. <span style="color: tomato">{{ item.puQty }}</span>
  87. <span> {{ item.puUnitName }}</span>
  88. </template>
  89. <el-descriptions-item label="需求组织">
  90. {{ item.demandOrgName }}
  91. </el-descriptions-item>
  92. <el-descriptions-item label="采购组织">
  93. {{ item.puOrgName }}
  94. </el-descriptions-item>
  95. <el-descriptions-item label="需求时间">
  96. {{ item.demandDate }}
  97. </el-descriptions-item>
  98. </el-descriptions>
  99. <el-table
  100. v-loading="loading"
  101. :data="item.orderPriceVos"
  102. style="width: 100%"
  103. >
  104. <el-table-column
  105. v-for="(cItem, cIndex) in tableColumns"
  106. :key="cIndex"
  107. :prop="cItem.key"
  108. :label="cItem.title"
  109. :fixed="cItem.fixed"
  110. :width="cItem.width || 180"
  111. show-overflow-tooltip
  112. >
  113. <template slot-scope="scope">
  114. <el-input-number
  115. v-if="cItem.inputType === 'InputNumber'"
  116. v-model="scope.row[cItem.key]"
  117. :size="size"
  118. :min="cItem.min(item)"
  119. :max="cItem.max(item)"
  120. :controls-position="cItem.controlsPosition"
  121. :placeholder="cItem.placeholder"
  122. style="width: 90%"
  123. ></el-input-number>
  124. <el-date-picker
  125. v-else-if="cItem.inputType === 'DatePicker'"
  126. v-model="scope.row[cItem.key]"
  127. :size="size"
  128. :type="cItem.type"
  129. :placeholder="cItem.placeholder"
  130. :picker-options="cItem.pickerOptions"
  131. :value-format="cItem.valueFormat"
  132. style="width: 90%"
  133. ></el-date-picker>
  134. <el-input
  135. v-else-if="cItem.inputType === 'Textarea'"
  136. v-model="scope.row[cItem.key]"
  137. :size="size"
  138. autosize
  139. type="textarea"
  140. style="width: 90%"
  141. ></el-input>
  142. <span v-else>{{ scope.row[cItem.key] }}</span>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <div slot="footer" style="text-align: right; margin-top: 10px">
  147. <el-button :size="size" @click="hide">取 消</el-button>
  148. <el-button :size="size" @click="submit">更 新</el-button>
  149. </div>
  150. </div>
  151. <!-- <el-pagination
  152. @size-change="handleSizeChange"
  153. @current-change="handleCurrentChange"
  154. :total="total"
  155. :page-sizes="pageSizes"
  156. :page-size="page.pageSize"
  157. :current-page="page.pageNum"
  158. hide-on-single-page
  159. layout="total, prev, pager, next, sizes, jumper"
  160. >
  161. </el-pagination> -->
  162. </el-dialog>
  163. </template>
  164. <style scoped></style>