addEditProduct.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div>
  3. <el-dialog :title="title" :visible.sync="dialogVisible" :before-close="handleClose" width="600px">
  4. <el-form :model="form" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  5. <el-form-item label="所属产品类别" prop="category">
  6. <el-input v-model="form.category" placeholder="请输入所属产品类别"></el-input>
  7. </el-form-item>
  8. <el-form-item label="产品名称" prop="name">
  9. <el-input v-model="form.name" placeholder="请输入产品名称"></el-input>
  10. </el-form-item>
  11. <el-form-item label="上市时间" prop="marketTime">
  12. <el-date-picker
  13. v-model="form.marketTime"
  14. type="date"
  15. placeholder="请选择上市时间"
  16. value-format="yyyy-MM-dd"
  17. style="width: 100%;">
  18. </el-date-picker>
  19. </el-form-item>
  20. <el-form-item label="所属公司" prop="company">
  21. <el-input v-model="form.company" :disabled="form.isTheCompany=='1'" placeholder="请输入所属公司"></el-input>
  22. </el-form-item>
  23. <el-form-item label="参考许可费率" prop="rate">
  24. <el-input v-model="form.rate" placeholder="请输入参考许可费率(介于 0 ~ 1 之间)"></el-input>
  25. </el-form-item>
  26. <el-form-item label="图片" prop="">
  27. <el-upload ref="upload" action="#" :auto-upload="false" :on-change="handleChange" list-type="picture"
  28. :show-file-list="false">
  29. <span v-if="form.pictures && form.pictures.length > 0" class="avatar">
  30. <span class="deleteImg">
  31. <span>
  32. <i class="el-icon-zoom-in" @click.stop="handlePictureCardPreview"></i>
  33. <i class="el-icon-delete" @click.stop="handleRemove"></i>
  34. </span>
  35. </span>
  36. <el-image ref="image" style="width:100%;height: 100%;"
  37. :src="form.pictures[0].id ? $p2 + form.pictures[0].url : form.pictures[0].url"
  38. :preview-src-list="form.pictures ? form.pictures.map(item => { return item.id ? $p2 + item.url : item.url }) : []"></el-image>
  39. </span>
  40. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  41. </el-upload>
  42. </el-form-item>
  43. <el-form-item label="产品说明" prop="">
  44. <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入产品说明"></el-input>
  45. </el-form-item>
  46. </el-form>
  47. <div slot="footer" class="dialog-footer">
  48. <el-button @click="handleClose">取消</el-button>
  49. <el-button type="primary" @click="submit">确定</el-button>
  50. </div>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. title: "",
  59. dialogVisible: false,
  60. form: {},
  61. rules: {
  62. category: [{ required: true, message: '请输入所属产品类别', trigger: 'blur' },],
  63. name: [{ required: true, message: '请输入产品名称', trigger: 'blur' },],
  64. },
  65. };
  66. },
  67. mounted() { },
  68. methods: {
  69. // 上传的change
  70. handleChange(file, fileList) { },
  71. // 点击已上传的文件
  72. handlePictureCardPreview(file) { },
  73. // 文件列表移除文件
  74. handleRemove(file) { },
  75. // 打开弹窗
  76. open(row) {
  77. this.form = JSON.parse(JSON.stringify(row))
  78. if (this.form.id) {
  79. this.title = '编辑产品类别'
  80. } else {
  81. if (this.form.isTheCompany=='1') {
  82. this.title = '新增本公司产品'
  83. } else {
  84. this.title = '新增外公司产品'
  85. }
  86. }
  87. this.dialogVisible = true;
  88. },
  89. // 弹窗确定
  90. submit() {
  91. this.$refs.ruleForm.validate(valid => {
  92. if (valid) {
  93. this.handleClose()
  94. } else {
  95. }
  96. })
  97. },
  98. // 弹窗取消/关闭
  99. handleClose() {
  100. this.$refs.ruleForm.resetFields()
  101. this.dialogVisible = false;
  102. },
  103. },
  104. };
  105. </script>
  106. <style lang="scss">
  107. .el-table__row{
  108. border: 1px solid black !important;
  109. }
  110. </style>
  111. <style lang="scss" scoped>
  112. .avatar-uploader-icon {
  113. background-color: #fbfdff;
  114. border: 1px dashed #c0ccda;
  115. font-size: 28px;
  116. color: #8c939d;
  117. width: 148px;
  118. height: 148px;
  119. line-height: 148px;
  120. text-align: center;
  121. }
  122. .avatar {
  123. position: relative;
  124. width: 148px;
  125. height: 148px;
  126. display: block;
  127. }
  128. .avatar:hover .deleteImg {
  129. display: block;
  130. }
  131. .deleteImg {
  132. display: none;
  133. font-size: 30px;
  134. width: 148px;
  135. height: 148px;
  136. background-color: black;
  137. opacity: 0.6;
  138. position: absolute;
  139. top: 0;
  140. right: 0;
  141. left: 0;
  142. bottom: 0;
  143. margin: auto;
  144. z-index: 999;
  145. }
  146. .deleteImg span i {
  147. margin-left: 10px;
  148. color: #fff;
  149. }
  150. .deleteImg span {
  151. display: flex;
  152. align-items: center;
  153. /*垂直居中*/
  154. justify-content: center;
  155. /*水平居中*/
  156. width: 100%;
  157. height: 100%;
  158. }</style>