table.vue 6.3 KB

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