addGroup.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="dialogTableVisible=true">新增产品组</el-button>
  4. <el-dialog title="新增产品组" append-to-body :visible.sync="dialogTableVisible" width="30%">
  5. <el-row :gutter="20">
  6. <el-form label-position="right" ref="form" :rules="rules" inline label-width="100px" :model="form" size="small">
  7. <el-col :span="24">
  8. <el-form-item label="产品组名称" prop="groupname">
  9. <el-input v-model="form.groupname" placeholder="请输入商品组名称"></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="24">
  13. <el-form-item label="品牌" prop="sa_brandid">
  14. <el-select v-model="form.sa_brandid" placeholder="请选择品牌">
  15. <el-option
  16. v-for="item in brandData"
  17. :key="item.sa_brandid"
  18. :label="item.brandname"
  19. :value="item.sa_brandid"
  20. size="small">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="24">
  26. <el-form-item label="商品" prop="itemno">
  27. <el-select v-model="form.itemno" placeholder="请选择商品">
  28. <el-option
  29. v-for="item in productData"
  30. :key="item.itemno"
  31. :label="item.itemname"
  32. :value="item.itemno"
  33. size="small">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="24">
  39. <el-form-item label="自定义标签" prop="tag" style="margin-bottom:0px; !important">
  40. <el-tag
  41. :key="tag"
  42. v-for="tag in form.tag"
  43. closable
  44. :disable-transitions="false"
  45. @close="handleClose(tag)">
  46. {{tag}}
  47. </el-tag>
  48. <el-input
  49. class="input-new-tag"
  50. v-if="inputVisible"
  51. v-model="inputValue"
  52. ref="saveTagInput"
  53. size="small"
  54. @keyup.enter.native="handleInputConfirm"
  55. @blur="handleInputConfirm"
  56. >
  57. </el-input>
  58. <el-button v-else class="button-new-tag" size="small" @click="showInput">+ New 标签</el-button>
  59. </el-form-item>
  60. </el-col>
  61. </el-form>
  62. </el-row>
  63. <span slot="footer" class="dialog-footer">
  64. <div>
  65. <el-button @click="dialogTableVisible = false" size="small">取 消</el-button>
  66. <el-button type="primary" @click="submit" size="small">确 定</el-button>
  67. </div>
  68. </span>
  69. </el-dialog>
  70. </div>
  71. </template>
  72. <script>
  73. export default {
  74. data () {
  75. return {
  76. dialogTableVisible:false,
  77. /* 当前选择的组 */
  78. seleteGroup:'',
  79. inputVisible: false,
  80. inputValue: '',
  81. form:{
  82. sa_brandid:'',
  83. groupname:'',
  84. itemno:'',
  85. tag:[]
  86. },
  87. rules:{
  88. sa_brandid: [
  89. { required: true, message: '请选择品牌', trigger: 'blur' },
  90. ],
  91. groupname: [
  92. { required: true, message: '请输入商品组名称', trigger: 'blur' },
  93. ],
  94. itemno: [
  95. { required: true, message: '请选择商品', trigger: 'blur' },
  96. ]
  97. }
  98. }
  99. },
  100. props:['type','brandData','productData','groupData'],
  101. watch: {
  102. },
  103. created() {
  104. },
  105. methods: {
  106. submit() {
  107. this.$refs.form.validate(async val => {
  108. if(val) {
  109. let res = await this.$api.requested({
  110. "id": "20220922164303",
  111. "version":1,
  112. "content": {
  113. "sa_itemgroupid":0,
  114. "sa_brandid":this.form.sa_brandid,
  115. "groupname":this.form.groupname,
  116. "itemno":this.form.itemno,
  117. "tag": this.form.tag
  118. }
  119. })
  120. this.tool.showMessage(res,() => {
  121. this.$emit('addSuccess')
  122. this.dialogTableVisible = false
  123. })
  124. }
  125. })
  126. },
  127. editBtn() {
  128. this.dialogTableVisible = true
  129. this.seleteGroup = this.groupData
  130. let temp = JSON.parse(JSON.stringify(this.seleteGroup))
  131. this.form = {
  132. sa_brandid:temp.sa_brandid,
  133. groupname:temp.groupname,
  134. itemno:temp.itemno,
  135. tag:temp.tag1
  136. }
  137. },
  138. handleClose(tag) {
  139. this.form.tag.splice(this.form.tag.indexOf(tag), 1);
  140. },
  141. showInput() {
  142. this.inputVisible = true;
  143. this.$nextTick(_ => {
  144. this.$refs.saveTagInput.$refs.input.focus();
  145. });
  146. },
  147. handleInputConfirm() {
  148. let inputValue = this.inputValue;
  149. if (inputValue) {
  150. this.form.tag.push(inputValue);
  151. }
  152. this.inputVisible = false;
  153. this.inputValue = '';
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. /deep/.el-dialog__body {
  160. padding-top: 10px !important;
  161. padding-bottom: 0 !important;
  162. }
  163. /deep/.dialog-footer {
  164. margin-top: 10px !important;
  165. }
  166. /deep/.el-form-item__content {
  167. width: calc(100% - 100px) !important;
  168. }
  169. /deep/.el-select {
  170. width: 100% !important;
  171. }
  172. /deep/.el-form-item {
  173. width: 100% !important;
  174. }
  175. .el-tag + .el-tag {
  176. margin-left: 10px;
  177. margin-bottom: 10px;
  178. }
  179. .button-new-tag {
  180. margin-left: 10px;
  181. height: 32px;
  182. line-height: 30px;
  183. padding-top: 0;
  184. padding-bottom: 0;
  185. }
  186. .input-new-tag {
  187. width: 90px;
  188. margin-left: 10px;
  189. }
  190. </style>