addOrEditSample.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :append-to-body="true"
  6. :visible.sync="visible"
  7. :close-on-click-modal="false"
  8. width="60%"
  9. @close="cancel"
  10. :maxable="true"
  11. :resizable="true"
  12. :title="title"
  13. >
  14. <headerTitle title="基本信息"></headerTitle>
  15. <el-form
  16. label-width="120px"
  17. ref="baseInfoRef"
  18. :model="form"
  19. :rules="rules"
  20. class="el-form-box"
  21. >
  22. <el-row>
  23. <!-- <el-col :span="8">
  24. <el-form-item label="物品名称:" prop="categoryName">
  25. <el-input
  26. placeholder="请输入"
  27. v-model="form.categoryName"
  28. maxlength="50"
  29. :disabled="type == 'view'"
  30. ></el-input>
  31. </el-form-item>
  32. </el-col> -->
  33. <el-col :span="8">
  34. <el-form-item label="样品类型:" prop="conditionType">
  35. <el-select
  36. v-model="form.conditionType"
  37. placeholder="请选择物品类型"
  38. width="100%"
  39. :disabled="type == 'detail'"
  40. >
  41. <el-option
  42. v-for="item in sampleList"
  43. :key="item.id"
  44. :label="item.label"
  45. :value="item.id"
  46. >
  47. </el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="8">
  52. <el-form-item label="样品编码:">
  53. <el-input
  54. disabled
  55. v-model="form.sampleCode"
  56. maxlength="50"
  57. ></el-input>
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. </el-form>
  62. <headerTitle title="样品列表"></headerTitle>
  63. <sampleTable
  64. ref="inventoryTable"
  65. :pricingWay="form.pricingWay"
  66. :isSinglePrice="false"
  67. :isTotalCount="false"
  68. :isDiscount="false"
  69. :isTemporary="true"
  70. :dataList="dataList"
  71. pageName="businessOpportunity"
  72. @changesMainNumberModal="changesMainNumberModal"
  73. ></sampleTable>
  74. <div slot="footer" class="footer">
  75. <el-button type="primary" @click="save('baseInfoRef')">保存</el-button>
  76. <el-button @click="cancel">返回</el-button>
  77. </div>
  78. </ele-modal>
  79. </template>
  80. <script>
  81. import dictMixins from '@/mixins/dictMixins';
  82. import sampleTable from './sampleTable.vue';
  83. import { getCode } from '@/api/login';
  84. export default {
  85. components: {
  86. sampleTable
  87. },
  88. mixins: [dictMixins],
  89. data() {
  90. return {
  91. imgs: [],
  92. title: '',
  93. visible: false,
  94. type: '',
  95. fullscreen: false,
  96. form: {
  97. pricingWay: [],
  98. conditionType: '',
  99. categoryCode: ''
  100. },
  101. // form: copyObj(formDef),
  102. // 提交状态
  103. loading: false,
  104. // 是否是修改
  105. isUpdate: false,
  106. gList: [], //商品分类
  107. levelList: [],
  108. sampleList: [
  109. { id: 1, label: '整样' },
  110. { id: 2, label: '小样' }
  111. ],
  112. rules: {
  113. conditionType: [
  114. { required: true, message: '请选择商品分类', trigger: 'change' }
  115. ]
  116. },
  117. dataList: []
  118. };
  119. },
  120. methods: {
  121. //打开弹出框
  122. async open(type, row, contactCategoryId) {
  123. // this.$refs.inventoryTable.resetTable()
  124. // this.form.categoryLevelId = contactCategoryId;
  125. this.title =
  126. type === 'add' ? '新增' : type === 'view' ? '详情' : '修改';
  127. this.type = type;
  128. this.visible = true;
  129. // if (type == 'add') {
  130. // this.isUpdate = false;
  131. // } else {
  132. // this.isUpdate = true;
  133. // }
  134. // if (type != 'add') {
  135. // // this.getGoodsById(row.id);
  136. // }
  137. },
  138. cancel() {},
  139. save(formName) {
  140. this.$refs[formName].validate((valid) => {
  141. if (valid) {
  142. if (this.dataList.length > 0) {
  143. }
  144. } else {
  145. console.log('error submit!!');
  146. return false;
  147. }
  148. });
  149. },
  150. async changesMainNumberModal(id, data) {
  151. // console.log(data.code);
  152. const newData = {};
  153. data.sampleCode = await this.getSampleCode();
  154. console.log(data.sampleCode);
  155. this.form.sampleCode = data.sampleCode;
  156. newData.sampleCode = data.sampleCode;
  157. newData.categoryCode = data.code;
  158. newData.categoryName = data.name;
  159. newData.batchNo = data.brandNum;
  160. newData.measureUnit = data.measuringUnit;
  161. newData.weightUnit = data.weightUnit;
  162. newData.weight = data.netWeight;
  163. this.dataList.push(newData);
  164. // if (data.measureType == 1) {
  165. // newData.measureUnit = data.measuringUnit;
  166. // } else if (data.measureType == 2) {
  167. // newData.measureUnit = data.weightUnit;
  168. // } else if (data.measureType == 3) {
  169. // newData.measureUnit = data.weightUnit;
  170. // } else if (data.measureType == 4) {
  171. // } else if (data.measureType == 5) {
  172. // }
  173. // this.dataList.push(data);
  174. // console.log(id, list);
  175. // this.form.categoryCode = data.sampleCode;
  176. },
  177. async getSampleCode() {
  178. return await getCode('sample_code');
  179. }
  180. }
  181. };
  182. </script>
  183. <style></style>