com-attr.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <style>
  2. .com-attr .box {
  3. line-height: 64px;
  4. border-top: 1px solid #E8EAEE;
  5. border-left: 1px solid #E8EAEE;
  6. border-right: 1px solid #E8EAEE;
  7. padding: 0 16px;
  8. }
  9. .com-attr .box .batch {
  10. margin-left: -10px;
  11. margin-right: 20px;
  12. }
  13. .com-attr .el-select .el-input {
  14. width: 130px;
  15. }
  16. .com-attr .input-with-select .el-input-group__prepend {
  17. background-color: #fff;
  18. }
  19. .com-attr .header-require:before {
  20. content: '*';
  21. color: #F56C6C;
  22. margin-right: 2px;
  23. }
  24. </style>
  25. <template id="com-attr">
  26. <div class="com-attr">
  27. <el-table ref="multipleTable" :data="cData" border stripe style="width: 100%" @selection-change="handleSelectionChange">
  28. <el-table-column v-if="cList"
  29. v-for="(item,index) in cList"
  30. :key="index"
  31. :label="item.label"
  32. :property="item.property"
  33. :index="item.index">
  34. <template slot-scope="scope">
  35. <template>
  36. <div v-if="scope.column.property == 'name'">
  37. {{scope.row[scope.column.property]}}
  38. </div>
  39. <el-input :disabled="!(scope.column.property == 'merchants_scale'||scope.column.property == 'venue_scale') " v-else-if="scope.column.property.indexOf('price') > -1 || scope.column.property.indexOf('level')" oninput="this.value = this.value.replace(/[^0-9]/g, '');" type="number" v-model="scope.row[scope.column.property]" @blur="itemInput(scope.column.property,scope.row[scope.column.property])">
  40. </el-input>
  41. <el-input v-else oninput="this.value = this.value.replace(/[^0-9]/g, '');" v-model="scope.row[scope.column.property]">
  42. <template v-if="append" slot="append">{{append}}</template>
  43. </el-input>
  44. </template>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. </div>
  49. </template>
  50. <script>
  51. Vue.component('com-attr', {
  52. template: '#com-attr',
  53. props: {
  54. value: Array, // 商品规格信息
  55. attrGroups: Array, // 商品规格组
  56. extra: Object, // 额外的数据信息
  57. list: Object | Array, // 从排列数据信息
  58. append: String, // 输入框后缀
  59. },
  60. data() {
  61. return {
  62. attrBatch: false,
  63. data: [
  64. {
  65. label: '规格名称',
  66. property: 'name'
  67. },
  68. {
  69. label: '原价',
  70. property: 'price'
  71. },
  72. {
  73. label: '重量(克)',
  74. property: 'weight'
  75. },
  76. {
  77. label: '货号',
  78. property: 'no'
  79. },
  80. {
  81. label: '规格库存',
  82. property: 'stock'
  83. },
  84. {
  85. label: '招商负责人',
  86. property: 'merchants_scale'
  87. },
  88. {
  89. label: '场地负责人',
  90. property: 'venue_scale'
  91. },
  92. ],
  93. selectData: '',
  94. batch: 0,
  95. selectList: [],
  96. };
  97. },
  98. created() {},
  99. watch: {
  100. 'selectList'(oldData, newData) {
  101. const self = this;
  102. let sign = 0;
  103. this.value.forEach(function(item, index) {
  104. self.selectList.map((item1) => {
  105. if (JSON.stringify(item1.attr_list) === JSON.stringify(item.attr_list)) {
  106. sign++;
  107. }
  108. });
  109. });
  110. self.attrBatch = self.value.length === sign;
  111. }
  112. },
  113. computed: {
  114. cList() {
  115. return this.data;
  116. },
  117. cData() {
  118. if (this.value.length > 0) {
  119. return this.value;
  120. } else {
  121. return this.attrGroups;
  122. }
  123. }
  124. },
  125. methods: {
  126. itemInput(e, f) {
  127. if (e == 'stock') {
  128. }
  129. },
  130. selectClick() {
  131. this.$refs.multipleTable.toggleAllSelection();
  132. },
  133. handleSelectionChange(data) {
  134. this.selectList = data;
  135. },
  136. batchAttr(param) {
  137. if (!param) {
  138. this.$message.warning('请选择批量设置');
  139. return;
  140. }
  141. if (!this.selectList || this.selectList.length === 0) {
  142. this.$message.warning('请勾选商品规格');
  143. return;
  144. }
  145. }
  146. }
  147. });
  148. </script>