add.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div>
  3. <el-button
  4. size="small"
  5. type="primary"
  6. @click="addBtn((dialogFormVisible = true))"
  7. >{{ $t(`新 建`) }}</el-button
  8. >
  9. <el-drawer
  10. :title="$t(`新建营销产品`)"
  11. :visible.sync="dialogFormVisible"
  12. size="60%"
  13. direction="rtl"
  14. append-to-body
  15. :show-close="false"
  16. @close="onClose"
  17. >
  18. <div class="drawer__panel">
  19. <el-row :gutter="20">
  20. <el-form :model="form" :rules="rules" ref="form" size="mini">
  21. <el-col :span="24">
  22. <el-form-item :label="$t(`商品`)" prop="itemname">
  23. <el-popover
  24. placement="bottom-start"
  25. width="700"
  26. trigger="click"
  27. v-model="dialogPopover"
  28. >
  29. <productTemplate
  30. :sa_fadid="form.sa_fadid"
  31. @selectPro="selectPro"
  32. ></productTemplate>
  33. <el-input
  34. slot="reference"
  35. v-model="form.itemname"
  36. :placeholder="$t(`选择商品`)"
  37. ></el-input>
  38. </el-popover>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="24">
  42. <el-form-item>
  43. <p style="font-size: 14px; margin-top: 10px">
  44. {{ $t("技术参数") }}
  45. </p>
  46. <div style="margin-top: 10px; min-height: 200px !important">
  47. <myEditor
  48. ref="technicalparam"
  49. height="360px"
  50. :content="form.technicalparam"
  51. :id="form.sa_fadid"
  52. ></myEditor>
  53. </div>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="24">
  57. <el-form-item>
  58. <p style="font-size: 14px; margin-top: 10px">
  59. {{ $t("材质说明") }}
  60. </p>
  61. <div style="margin-top: 10px; min-height: 200px !important">
  62. <myEditor
  63. ref="materialdescription"
  64. height="360px"
  65. :content="form.materialdescription"
  66. :id="form.sa_fadid"
  67. ></myEditor>
  68. </div>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="24">
  72. <el-form-item>
  73. <p style="font-size: 14px; margin-top: 10px">
  74. {{ $t("产品概述") }}
  75. </p>
  76. <div style="margin-top: 10px; min-height: 200px !important">
  77. <myEditor
  78. ref="contentstr"
  79. height="360px"
  80. :content="form.contentstr"
  81. :id="form.sa_fadid"
  82. ></myEditor>
  83. </div>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="24">
  87. <el-form-item :label="$t('分类')" prop="classmx">
  88. <el-cascader
  89. ref="selectdep"
  90. size="small"
  91. style="width: 100%"
  92. :placeholder="$t('分类')"
  93. v-model="form.classmx"
  94. :options="classData"
  95. filterable
  96. :props="{
  97. emitPath: false,
  98. expandTrigger: 'hover',
  99. checkStrictly: false,
  100. label: 'remarks',
  101. value: 'value',
  102. children: 'subvalues',
  103. }"
  104. clearable
  105. ></el-cascader>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="24">
  109. <div class="upload-box">
  110. <div class="label" style="margin-top: 3px">
  111. {{ $t("产品资料") }}
  112. </div>
  113. <upload
  114. :classType="['image', 'video', 'document', 'pdf']"
  115. @oploadIng="oploadIng"
  116. ref="upload"
  117. >
  118. <div style="width: 400px; text-align: left">
  119. <el-button size="small" type="primary">
  120. <span
  121. class="icon iconfont"
  122. style="margin-right: 5px; font-size: 14px"
  123. >&#xe63b;</span
  124. >
  125. {{ $t("点击上传") }}
  126. </el-button>
  127. </div>
  128. </upload>
  129. </div>
  130. </el-col>
  131. <el-col :span="24">
  132. <el-form-item :label="$t('状态')" prop="status">
  133. <el-radio-group v-model="form.isonsale" style="width: 100%">
  134. <el-radio label="0">{{ $t("新建") }}</el-radio>
  135. <el-radio label="1">{{ $t(`发布`) }}</el-radio>
  136. </el-radio-group>
  137. </el-form-item>
  138. </el-col>
  139. </el-form>
  140. </el-row>
  141. </div>
  142. <div class="fixed__btn__panel">
  143. <el-button
  144. size="small"
  145. @click="onClose"
  146. plain
  147. class="normal-btn-width"
  148. :disabled="loading || disabled"
  149. >{{ $t(`取 消`) }}</el-button
  150. >
  151. <el-button
  152. size="small"
  153. type="primary"
  154. @click="onSubmit"
  155. class="normal-btn-width"
  156. :disabled="disabled"
  157. :loading="loading"
  158. >{{ $t(`确 定`) }}</el-button
  159. >
  160. </div>
  161. </el-drawer>
  162. </div>
  163. </template>
  164. <script>
  165. import upload from "../compents/upload";
  166. import productTemplate from "@/WebsiteManagement/marketproductMag/compents/productTemplate";
  167. import myEditor from "@/components/my-editor/Editor.vue";
  168. export default {
  169. name: "add",
  170. components: { productTemplate, myEditor, upload },
  171. data() {
  172. return {
  173. dialogFormVisible: false,
  174. dialogPopover: false,
  175. loading: false,
  176. disabled: false,
  177. classData: [],
  178. form: {
  179. siteid: JSON.parse(sessionStorage.getItem("active_account")).siteid,
  180. sa_fadid: 0, //sa_brandid<=0时 为新增
  181. itemid: "",
  182. itemname: "",
  183. itemno: "",
  184. class: "",
  185. materialdescription: "",
  186. technicalparam: "",
  187. contentstr: "",
  188. isonsale: "1",
  189. classmx: "",
  190. },
  191. rules: {
  192. itemname: [
  193. { required: true, message: this.$t("请选择商品"), trigger: "change" },
  194. ],
  195. classmx: [
  196. { required: true, message: this.$t("请选择分类"), trigger: "change" },
  197. ],
  198. },
  199. };
  200. },
  201. mounted() {},
  202. methods: {
  203. oploadIng(e) {
  204. this.disabled = e;
  205. },
  206. addBtn() {
  207. this.queryClass();
  208. },
  209. onSubmit() {
  210. this.$refs.form.validate(async (valid) => {
  211. if (!valid) return false;
  212. this.loading = true;
  213. this.form.technicalparam = this.$refs.technicalparam.html;
  214. this.form.materialdescription = this.$refs.materialdescription.html;
  215. this.form.contentstr = this.$refs.contentstr.html;
  216. const selectdep = this.$refs.selectdep._data.inputValue.split(" / ");
  217. this.form.class = selectdep[0] || "";
  218. this.form.classmx = selectdep[1] || "";
  219. const res = await this.$api.requested({
  220. id: "20240920101303",
  221. content: this.form,
  222. });
  223. await this.$refs.upload.rebinding("sa_fad", res.data.sa_fadid);
  224. this.tool.showMessage(res, async () => {
  225. const res1 = await this.$api.requested({
  226. id: "20240920101603",
  227. content: {
  228. siteid: this.form.siteid,
  229. sa_fadids: [res.data.sa_fadid],
  230. isonsale: this.form.isonsale,
  231. },
  232. });
  233. this.dialogFormVisible = false;
  234. this.onClose();
  235. });
  236. });
  237. },
  238. selectPro(data) {
  239. this.dialogPopover = false;
  240. this.form.itemname = data.itemname;
  241. this.form.itemid = data.itemid;
  242. this.form.itemno = data.itemno;
  243. },
  244. async queryClass() {
  245. const res = await this.$store.dispatch(
  246. "optiontypeselect",
  247. "marketproductclass"
  248. );
  249. res.data.push({
  250. remarks: "测试",
  251. value: "测试",
  252. subvalues: [],
  253. });
  254. this.classData = [];
  255. this.classData = res.data.map((item) => {
  256. let data = {
  257. value: item.value,
  258. remarks: item.remarks,
  259. };
  260. if (item.subvalues.length)
  261. data.subvalues = item.subvalues.map((k) => {
  262. return {
  263. value: k,
  264. remarks: k,
  265. };
  266. });
  267. return data;
  268. });
  269. },
  270. onClose() {
  271. this.dialogFormVisible = false;
  272. this.loading = false;
  273. this.$refs.form.resetFields();
  274. this.$refs.upload.deleteAllTemporaryFiles();
  275. this.$refs.technicalparam.html = "";
  276. this.$refs.materialdescription.html = "";
  277. this.$refs.contentstr.html = "";
  278. this.$emit("onSuccess");
  279. },
  280. },
  281. };
  282. </script>
  283. <style scoped>
  284. .upload-box {
  285. width: 100%;
  286. display: flex;
  287. padding: 10px 0 13px;
  288. }
  289. .upload-box .label {
  290. font-size: 14px;
  291. margin-right: 20px;
  292. margin-top: 3px;
  293. color: #606266;
  294. }
  295. </style>