fixed-price-form.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <el-form
  3. v-loading="loading"
  4. ref="ruleForm"
  5. :model="ruleForm"
  6. status-icon
  7. :rules="rulesThis"
  8. :label-width="labelWidth || '110px'"
  9. class="demo-ruleForm-goodsOnline"
  10. :size="'mini'"
  11. >
  12. <el-row>
  13. <el-col :span="24"
  14. ><el-form-item label="售价凭证类型" prop="proof_type">
  15. <el-radio-group
  16. v-model="ruleForm.proof_type"
  17. @change="set_proof_url()"
  18. >
  19. <el-radio
  20. v-for="item in options"
  21. :key="item.value"
  22. :label="item.value"
  23. >{{ item.label }}</el-radio
  24. >
  25. </el-radio-group>
  26. <el-button class="fr" type="primary" @click="showVoucher = true"
  27. >查看历史凭证</el-button
  28. >
  29. </el-form-item>
  30. <show-voucher-model
  31. :showModel="showVoucher"
  32. :id="spuCode"
  33. @cancel="showVoucher = false"
  34. @searchChange="resvoucher"
  35. />
  36. </el-col>
  37. <el-col :span="24">
  38. <el-form-item label="凭证文件" prop="proof_url">
  39. <ul class="shangchuan-ul">
  40. <li v-if="ruleForm.proof_type === '1'" class="shiping">
  41. <div v-if="video_url" class="clearfix">
  42. <video width="250" controls class="fl">
  43. <source :src="video_url" type="video/mp4" />
  44. <source :src="video_url" type="video/avi" />
  45. 您的浏览器不支持Video标签。
  46. </video>
  47. <el-link
  48. :underline="false"
  49. @click="deleteUrl('1')"
  50. type="warning"
  51. style="margin: 0 0 0 16px"
  52. >删除</el-link
  53. >
  54. </div>
  55. <div class="activity-upload" v-else>
  56. <div class="btnupload" style="position: relative">
  57. <i class="el-icon-plus avatar-uploader-icon"></i>
  58. <video-upload
  59. class="Upload"
  60. :disabled="type === 'view' || type === 'editCoin'"
  61. :accept="'.mp4,.avi'"
  62. :multiple="false"
  63. :uploadcondition="beforeVideoUpload"
  64. @UploadErrorEvent="UploadVideoEventproof_url"
  65. @UploadSuccessEvent="UploadSuccessVideoproof_url"
  66. />
  67. </div>
  68. <div class="txt-tips fl">
  69. <p>建议大小:小于10MB</p>
  70. <p>文件格式:.mp4,.avi</p>
  71. </div>
  72. </div>
  73. </li>
  74. <li v-if="ruleForm.proof_type === '2'" class="tupian">
  75. <div v-if="img_url" class="clearfix">
  76. <img
  77. style="width: 84px; height: 84px"
  78. :src="img_url"
  79. class="avatar fl"
  80. />
  81. <el-link
  82. :underline="false"
  83. @click="deleteUrl('2')"
  84. type="warning"
  85. style="margin: 0 0 0 16px"
  86. >删除</el-link
  87. >
  88. </div>
  89. <div class="activity-upload" v-else>
  90. <div class="btnupload" style="position: relative">
  91. <i class="el-icon-plus avatar-uploader-icon"></i>
  92. <file-upload
  93. class="Upload"
  94. :disabled="type === 'view' || type === 'editCoin'"
  95. :accept="'.jpg,.png,.jpeg'"
  96. :multiple="false"
  97. :uploadcondition="beforeAvatarUpload"
  98. @UploadErrorEvent="UploadErrorEventproof_url"
  99. @UploadSuccessEvent="UploadSuccessEventproof_url"
  100. ></file-upload>
  101. </div>
  102. <div class="txt-tips fl">
  103. <p>建议大小:小于1MB</p>
  104. <p>文件格式:.jpg,.png,.jpeg</p>
  105. </div>
  106. </div>
  107. </li>
  108. <li v-if="ruleForm.proof_type === '3'" class="qita">
  109. <div v-if="other_url" class="clearfix">
  110. <a :href="other_url" download="凭证文件">点击下载</a>
  111. <el-link
  112. :underline="false"
  113. @click="deleteUrl('3')"
  114. type="warning"
  115. style="margin: 0 0 0 16px"
  116. >删除</el-link
  117. >
  118. </div>
  119. <div class="activity-upload" v-else>
  120. <div class="btnupload" style="position: relative">
  121. <i class="el-icon-plus avatar-uploader-icon"></i>
  122. <file-upload-pdf
  123. class="Upload"
  124. :accept="'.xlsx,.xls,.pdf,.zip,.rar,.7z'"
  125. :multiple="false"
  126. :uploadcondition="beforeOtherUpload"
  127. @UploadErrorEvent="UploadErrorOtherproof_url"
  128. @UploadSuccessEvent="UploadSuccessOtherproof_url"
  129. />
  130. </div>
  131. <div class="txt-tips fl">
  132. <p>建议大小:小于5MB</p>
  133. <p>文件格式:.xlsx,.xls,.pdf,.zip,.rar,.7z</p>
  134. </div>
  135. </div>
  136. </li>
  137. </ul>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="24">
  141. <el-table
  142. :data="ruleForm.good_ladder"
  143. :size="'mini'"
  144. border
  145. stripe
  146. style="width: 100%; margin: 0 0 20px 0"
  147. >
  148. <el-table-column prop="min_num" label="起订量(>=)" />
  149. <el-table-column prop="sale_price" label="售价" />
  150. <el-table-column prop="market_price" label="市场价" />
  151. <el-table-column prop="market_platform" label="对比平台" />
  152. <el-table-column prop="status" label="状态" />
  153. <el-table-column fixed="right">
  154. <template slot="header" slot-scope="scope">
  155. <span>操作</span>
  156. <el-tooltip effect="dark" content="添加阶梯" placement="top">
  157. <i
  158. class="el-icon-circle-plus-outline tb-icon fr"
  159. @click="openCostEdit(-1, {})"
  160. ></i>
  161. </el-tooltip>
  162. </template>
  163. <template slot-scope="scope">
  164. <el-tooltip effect="dark" content="修改" placement="top">
  165. <i
  166. class="el-icon-edit tb-icon"
  167. @click="openCostEdit(scope.$index, scope.row)"
  168. ></i>
  169. </el-tooltip>
  170. <el-tooltip effect="dark" content="删除" placement="top">
  171. <i
  172. class="el-icon-delete tb-icon"
  173. @click="openCostEditDelete(scope.$index)"
  174. ></i>
  175. </el-tooltip>
  176. </template>
  177. </el-table-column>
  178. </el-table>
  179. <!-- 弹窗 新增/修改 -->
  180. <cost-form-add-edit
  181. :index="costmodelIndex"
  182. :show-model="costshowModel"
  183. :sitem="costsitem"
  184. @refresh="costrefreshEdit"
  185. @cancel="costshowModel = false"
  186. />
  187. <el-form-item class="fr">
  188. <el-button
  189. v-if="!isDetail"
  190. :size="'mini'"
  191. type="primary"
  192. @click="submitForm"
  193. >保 存
  194. </el-button>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. </el-form>
  199. </template>
  200. <script>
  201. import costFormAddEdit from "./costFormAddEdit";
  202. import asyncRequest from "@/apis/service/goodStore/goodsOnline";
  203. import showVoucherModel from "@/components/show-voucher-model";
  204. export default {
  205. name: "exam-form",
  206. props: [
  207. "size",
  208. "statusList",
  209. "disabled",
  210. "isMust",
  211. "labelWidth",
  212. "id",
  213. "spuCode",
  214. ],
  215. components: {
  216. costFormAddEdit,
  217. showVoucherModel,
  218. },
  219. /**
  220. * 属性集合
  221. * @param {String} size : 组件大小 非必填
  222. * @param {Array} statusList : 驳回至备选项 必填
  223. * @param {Boolean} disabled : 是否禁用 必填
  224. * @param {Boolean} isMust : 是否需要展示驳回节点 必填
  225. *
  226. *
  227. */
  228. /**
  229. * 事件集合
  230. * @searchChange : 选中值变化调用 抛出选中数据
  231. */
  232. data() {
  233. return {
  234. loading: false,
  235. showVoucher: false,
  236. video_url: "",
  237. img_url: "",
  238. other_url: "",
  239. options: [
  240. {
  241. value: "1",
  242. label: "视频",
  243. },
  244. {
  245. value: "2",
  246. label: "图片",
  247. },
  248. {
  249. value: "3",
  250. label: "其他",
  251. },
  252. ],
  253. showModelThis: this.showModel,
  254. pickerOptions: {
  255. disabledDate(time) {
  256. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  257. },
  258. },
  259. costshowModel: false,
  260. costmodelIndex: "",
  261. costsitem: {},
  262. ruleForm: {
  263. skuCode: "",
  264. proof_type: "1", // 通过or驳回
  265. proof_url: "", //驳回至
  266. good_ladder: [],
  267. },
  268. rulesThis: this.rules,
  269. rules: {
  270. proof_type: [
  271. {
  272. required: true,
  273. message: "请选择审核状态",
  274. trigger: "change",
  275. },
  276. ],
  277. proof_url: [
  278. {
  279. required: true,
  280. message: "请上传凭证文件",
  281. trigger: "change",
  282. },
  283. ],
  284. rebut: [
  285. {
  286. required: true,
  287. message: "请选择驳回节点",
  288. trigger: "change",
  289. },
  290. ],
  291. remark: [
  292. { required: true, message: "请输入审核备注", trigger: "blur" },
  293. {
  294. min: 1,
  295. max: 250,
  296. message: "长度在 1 到 250 个字符",
  297. trigger: "blur",
  298. },
  299. ],
  300. },
  301. };
  302. },
  303. watch: {
  304. isDetail: function (val, old) {
  305. if (this.isDetail !== val) {
  306. this.options = [];
  307. this.selectLoading = false;
  308. }
  309. },
  310. },
  311. mounted() {
  312. this.initForm();
  313. },
  314. methods: {
  315. async initForm() {
  316. console.log(this.spuCode);
  317. this.loading = true;
  318. this.rulesThis = this.rules;
  319. await this.resetForm();
  320. this.loading = false;
  321. },
  322. openCostEdit(index, sitem) {
  323. this.costmodelIndex = index;
  324. this.costsitem = sitem;
  325. this.costshowModel = true;
  326. },
  327. openCostEditDelete(index) {
  328. this.ladder_tableData.splice(index, 1);
  329. },
  330. //阶梯成本修改
  331. costrefreshEdit(e) {
  332. let item = JSON.parse(JSON.stringify(e));
  333. console.log(item);
  334. const {
  335. index,
  336. id,
  337. min_num,
  338. sale_price,
  339. market_price,
  340. market_platform,
  341. status,
  342. is_del,
  343. } = item;
  344. if (index + "" === "-1") {
  345. this.ruleForm.good_ladder.push(item);
  346. } else {
  347. this.ruleForm.good_ladder.forEach((i, findex) => {
  348. if (i.id === id && findex === parseInt(i.index)) {
  349. this.ruleForm.good_ladder[findex].id = id;
  350. this.ruleForm.good_ladder[findex].sale_price = sale_price;
  351. this.ruleForm.good_ladder[findex].market_price = market_price;
  352. this.ruleForm.good_ladder[findex].min_num = min_num;
  353. this.ruleForm.good_ladder[findex].market_platform = market_platform;
  354. this.ruleForm.good_ladder[findex].status = status;
  355. this.ruleForm.good_ladder[findex].id_del = is_del;
  356. }
  357. });
  358. // this.ladder_tableData = this.ladder_tableData.sort(
  359. // this.dataSort("min_num")
  360. // );
  361. }
  362. this.showModel = false;
  363. },
  364. async resetForm() {
  365. // 重置
  366. await this.$nextTick(() => {
  367. if (this.$refs.ruleForm) {
  368. this.$refs.ruleForm.resetFields();
  369. this.$refs.ruleForm.clearValidate();
  370. this.ruleForm = {
  371. skuCode: this.id,
  372. proof_type: "1", // 通过or驳回
  373. proof_url: "", //驳回至
  374. good_ladder: [],
  375. };
  376. }
  377. });
  378. },
  379. async submitForm() {
  380. await this.$refs.ruleForm.validate(async (valid) => {
  381. if (valid) {
  382. let model = JSON.parse(JSON.stringify(this.ruleForm));
  383. let list = JSON.parse(JSON.stringify(model.good_ladder));
  384. let list2 = [];
  385. list.forEach((e) => {
  386. let n = JSON.parse(JSON.stringify(e));
  387. for (let key in n) {
  388. n[key] += "";
  389. }
  390. delete n["index"];
  391. list2.push(n);
  392. });
  393. model.good_ladder = list2;
  394. model.skuCode = this.id;
  395. let res = await asyncRequest.ladderOne(model);
  396. this.loading = false;
  397. if (res && res.code === 0) {
  398. this.$notify.success({
  399. title: "信息提交成功",
  400. message: "",
  401. });
  402. // this.showModelThis = false;
  403. // 刷新
  404. this.$emit("resSuccess", true);
  405. // this.routeReGoto("goodsOnline", {});
  406. }
  407. } else {
  408. console.log("error submit!!");
  409. return false;
  410. }
  411. });
  412. },
  413. resvoucher(e) {
  414. const { proof_type, proof_url } = e;
  415. this.ruleForm.proof_type = proof_type || "1";
  416. switch (this.ruleForm.proof_type) {
  417. case "1":
  418. this.video_url = proof_url;
  419. break;
  420. case "2":
  421. this.img_url = proof_url;
  422. break;
  423. case "3":
  424. this.other_url = proof_url;
  425. break;
  426. default:
  427. this.video_url = proof_url;
  428. }
  429. this.set_proof_url();
  430. },
  431. //图片上传成功
  432. async UploadSuccessEventproof_url(data) {
  433. const { url } = data;
  434. if (url === "noToken") {
  435. await this.logout();
  436. } else {
  437. this.img_url = url;
  438. this.set_proof_url();
  439. this.$message.success("图片上传成功!");
  440. }
  441. },
  442. //图片上传失败
  443. UploadErrorEventproof_url(res) {
  444. if (res !== "break") {
  445. this.set_proof_url();
  446. this.$message.error("图片上传失败!");
  447. }
  448. },
  449. //判断图片规格
  450. beforeAvatarUpload(file) {
  451. let isJPG = false;
  452. if (
  453. file.type === "image/jpg" ||
  454. file.type === "image/png" ||
  455. file.type === "image/jpeg"
  456. ) {
  457. isJPG = true;
  458. }
  459. const isLt2M = file.size / 1024 / 1024 < 1;
  460. if (!isJPG) {
  461. this.$message.error("图片格式不正确!");
  462. }
  463. if (!isLt2M) {
  464. this.$message.error("图片大小不能超过 1MB!");
  465. }
  466. return isJPG && isLt2M;
  467. },
  468. //视频上传成功
  469. async UploadSuccessVideoproof_url(data) {
  470. const { url } = data;
  471. if (url === "noToken") {
  472. await this.logout();
  473. } else {
  474. this.video_url = url;
  475. this.set_proof_url();
  476. this.$message.success("视频上传成功!");
  477. }
  478. },
  479. //视频上传失败
  480. UploadErrorVideoproof_url(res) {
  481. if (res !== "break") {
  482. this.set_proof_url();
  483. this.$message.error("视频上传失败!");
  484. }
  485. },
  486. //判断视频规格
  487. beforeVideoUpload(file) {
  488. let isJPG = false;
  489. if (file.type === "video/mp4" || file.type === "video/avi") {
  490. isJPG = true;
  491. }
  492. const isLt2M = file.size / 1024 / 1024 < 10;
  493. if (!isJPG) {
  494. this.$message.error("视频格式不正确!");
  495. }
  496. if (!isLt2M) {
  497. this.$message.error("视频大小不能超过 10MB!");
  498. }
  499. return isJPG && isLt2M;
  500. },
  501. // 其他文件上传成功
  502. async UploadSuccessOtherproof_url(data) {
  503. const { url } = data;
  504. if (url === "noToken") {
  505. await this.logout();
  506. } else {
  507. this.other_url = url;
  508. this.set_proof_url();
  509. this.$message.success("文件成功!");
  510. }
  511. },
  512. //其他文件上传失败
  513. UploadErrorOtherproof_url(res) {
  514. if (res !== "break") {
  515. this.set_proof_url();
  516. this.$message.error("文件上传失败!");
  517. }
  518. },
  519. //判断其他文件规格
  520. beforeOtherUpload(file) {
  521. console.log(file);
  522. let isJPG = false;
  523. if (
  524. file.type === "application/vnd.ms-excel" ||
  525. file.type ===
  526. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
  527. file.type === "application/pdf" ||
  528. file.type === "application/x-zip-compressed"
  529. ) {
  530. isJPG = true;
  531. }
  532. let name = file.name;
  533. let list = name.split(".");
  534. if (list[list.length - 1] === "rar" || list[list.length - 1] === "7z") {
  535. isJPG = true;
  536. }
  537. const isLt2M = file.size / 1024 / 1024 < 5;
  538. if (!isJPG) {
  539. this.$message.error("文件格式不正确!");
  540. }
  541. if (!isLt2M) {
  542. this.$message.error("文件大小不能超过 5MB!");
  543. }
  544. return isJPG && isLt2M;
  545. },
  546. deleteUrl(type) {
  547. switch (type) {
  548. case "1":
  549. this.video_url = "";
  550. break;
  551. case "2":
  552. this.img_url = "";
  553. break;
  554. case "3":
  555. this.other_url = "";
  556. break;
  557. default:
  558. this.video_url = "";
  559. }
  560. this.set_proof_url();
  561. },
  562. set_proof_url() {
  563. const { proof_type } = this.ruleForm;
  564. switch (proof_type) {
  565. case "1":
  566. this.ruleForm.proof_url = this.video_url;
  567. break;
  568. case "2":
  569. this.ruleForm.proof_url = this.img_url;
  570. break;
  571. case "3":
  572. this.ruleForm.proof_url = this.other_url;
  573. break;
  574. default:
  575. this.ruleForm.proof_url = this.video_url;
  576. }
  577. this.$refs.ruleForm.validateField("proof_url");
  578. },
  579. },
  580. };
  581. </script>
  582. <style lang="scss" scoped>
  583. .demo-ruleForm-goodsOnline {
  584. .shangchuan-ul {
  585. li {
  586. position: relative;
  587. width: 100%;
  588. &.tupian {
  589. }
  590. }
  591. }
  592. }
  593. </style>