table.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="table">
  3. <div class="header">
  4. <div class="header-item">
  5. <span>使用功效:</span>
  6. {{ pesticideFertilizerListItem.typeName }}
  7. </div>
  8. <div class="header-item">
  9. <div class="header-title">肥药名称:</div>
  10. <!-- <el-select class="select" v-model="value">
  11. <el-option v-for="item in list" :key="item.name" :label="item.name" :value="item.name" />
  12. </el-select> -->
  13. <el-select
  14. @change="handlePesticideFertilizerChange"
  15. v-model="pesticideFertilizerListItem.pesticideFertilizerId"
  16. placeholder="请选择"
  17. class="select"
  18. >
  19. <el-option
  20. v-for="item in pesticideFertilizersOptions"
  21. :key="item.id"
  22. :label="item.defaultName"
  23. :value="item.id"
  24. />
  25. </el-select>
  26. </div>
  27. </div>
  28. <div class="body">
  29. <div class="th">
  30. <div class="td"></div>
  31. <div class="td">配比<span>(药剂:兑水量)</span></div>
  32. <!-- <div class="td">施用方式</div> -->
  33. <div class="td">单亩用量</div>
  34. </div>
  35. <div class="tr">
  36. <div class="td">人工</div>
  37. <div class="td input-class">
  38. <el-input @change="emitVal" v-model="pesticideFertilizerListItem.ratio" placeholder="" size="small" />
  39. </div>
  40. <div class="td input-class">
  41. <el-input @change="emitVal" v-model="pesticideFertilizerListItem.muUsage" placeholder="" size="small" />
  42. </div>
  43. </div>
  44. <div class="tr" v-show="hasFly">
  45. <div class="td">无人机</div>
  46. <div class="td input-class">
  47. <el-input @change="emitVal" v-model="pesticideFertilizerListItem.ratio2" placeholder="" size="small" />
  48. </div>
  49. <div class="td input-class">
  50. <el-input @change="emitVal" v-model="pesticideFertilizerListItem.muUsage2" placeholder="" size="small" />
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { ref, onMounted, watch } from "vue";
  58. const props = defineProps({
  59. pesticideFertilizerList: {
  60. type: Object,
  61. default: () => {},
  62. },
  63. hasFly: {
  64. type: Boolean,
  65. default: true
  66. },
  67. pIndex: {},
  68. cIndex: {},
  69. });
  70. let pesticideFertilizerListItem = ref({
  71. key: 1,
  72. typeName: "",
  73. muUsage: "",
  74. muUsage2: "",
  75. ratio: "",
  76. ratio2: "",
  77. remark: "",
  78. });
  79. watch(() => props.pesticideFertilizerList, (newVal, oldVal) => {
  80. pesticideFertilizerListItem.value = props.pesticideFertilizerList
  81. })
  82. watch(() => props.hasFly, () => {})
  83. onMounted(() => {
  84. pesticideFertilizerListItem.value = props.pesticideFertilizerList;
  85. });
  86. let pesticideFertilizersOptions = ref([
  87. {
  88. id: "null",
  89. name: "芸苔素内酯 15000倍",
  90. typeName: "30",
  91. defaultRatio: null,
  92. defaultDroneRatio: null,
  93. unit: 0,
  94. defaultName: "调节",
  95. },
  96. ]);
  97. VE_API.order.pesticideFertilizers().then(({ data }) => {
  98. pesticideFertilizersOptions.value = data;
  99. });
  100. /**
  101. * 选择药肥的时候修改订单中药肥pesticideFertilizerId 以外其他数据
  102. * @param index
  103. */
  104. const handlePesticideFertilizerChange = () => {
  105. let obj = pesticideFertilizersOptions.value.filter(
  106. (item) => pesticideFertilizerListItem.value.pesticideFertilizerId === item.id
  107. )[0];
  108. pesticideFertilizerListItem.value = {
  109. ...pesticideFertilizerListItem.value,
  110. typeName: obj.typeName,
  111. unit: obj.unit,
  112. defaultRatio: obj.defaultRatio,
  113. usageModeList: obj.usageModeList,
  114. ratio: obj.defaultRatio,
  115. defaultName: obj.defaultName,
  116. pesticideFertilizerName: obj.name,
  117. pesticideFertilizerCode: obj.pesticideFertilizerCode,
  118. };
  119. console.log("ite", pesticideFertilizerListItem.value);
  120. };
  121. const emit = defineEmits(["updateTableData"])
  122. function emitVal() {
  123. emit("updateTableData", props.pIndex, props.cIndex, pesticideFertilizerListItem.value)
  124. }
  125. function getItem() {
  126. return pesticideFertilizerListItem.value
  127. }
  128. defineExpose({ getItem });
  129. </script>
  130. <style lang="scss" scoped>
  131. .table {
  132. .header {
  133. display: flex;
  134. justify-content: center;
  135. .header-item {
  136. display: flex;
  137. align-items: center;
  138. color: #727272;
  139. .header-title {
  140. flex: none;
  141. }
  142. }
  143. .header-item + .header-item {
  144. margin-left: 36px;
  145. }
  146. }
  147. .body {
  148. border: 1px solid #444444;
  149. border-radius: 5px;
  150. .th {
  151. border-bottom: 1px solid #444444;
  152. }
  153. .th,
  154. .tr {
  155. display: flex;
  156. align-items: center;
  157. color: #727272;
  158. height: 46px;
  159. font-size: 16px;
  160. .td {
  161. text-align: center;
  162. flex: 1;
  163. span {
  164. font-size: 11px;
  165. display: inline-block;
  166. }
  167. }
  168. .td + .td {
  169. border-left: 1px solid #444444;
  170. height: 46px;
  171. line-height: 46px;
  172. }
  173. }
  174. .tr + .tr {
  175. border-top: 1px solid #444444;
  176. }
  177. }
  178. .select {
  179. min-width: 110px;
  180. ::v-deep {
  181. .el-select__wrapper {
  182. background: transparent;
  183. padding: 0;
  184. box-shadow: none;
  185. }
  186. .el-select__placeholder,
  187. .el-select__caret {
  188. color: #ffd489;
  189. }
  190. }
  191. }
  192. .input-class {
  193. ::v-deep {
  194. .el-input {
  195. width: 90%;
  196. }
  197. .el-input__wrapper {
  198. background: transparent;
  199. box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
  200. }
  201. .el-input__inner {
  202. color: #ffd489;
  203. }
  204. }
  205. }
  206. }
  207. </style>