fixed-price-form.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. <template slot-scope="scope">
  154. <el-tag
  155. :size="'mini'"
  156. :type="scope.row.status == '1' ? '' : 'warning'"
  157. >{{ scope.row.status == "1" ? "启用" : "禁用" }}</el-tag
  158. >
  159. </template>
  160. </el-table-column>
  161. <el-table-column fixed="right">
  162. <template slot="header" slot-scope="scope">
  163. <span>操作</span>
  164. <el-tooltip effect="dark" content="添加阶梯" placement="top">
  165. <i
  166. class="el-icon-circle-plus-outline tb-icon fr"
  167. @click="openCostEdit(-1, {})"
  168. ></i>
  169. </el-tooltip>
  170. </template>
  171. <template slot-scope="scope">
  172. <el-tooltip effect="dark" content="修改" placement="top">
  173. <i
  174. class="el-icon-edit tb-icon"
  175. @click="openCostEdit(scope.$index, scope.row)"
  176. ></i>
  177. </el-tooltip>
  178. <el-tooltip effect="dark" content="删除" placement="top">
  179. <i
  180. class="el-icon-delete tb-icon"
  181. @click="openCostEditDelete(scope.$index)"
  182. ></i>
  183. </el-tooltip>
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. <!-- 弹窗 新增/修改 -->
  188. <cost-form-add-edit
  189. :index="costmodelIndex"
  190. :show-model="costshowModel"
  191. :sitem="costsitem"
  192. :spuCode="spuCode"
  193. @refresh="costrefreshEdit"
  194. @cancel="costshowModel = false"
  195. />
  196. <el-form-item class="fr">
  197. <el-button
  198. v-if="!isDetail"
  199. :size="'mini'"
  200. type="primary"
  201. @click="submitForm"
  202. >保 存
  203. </el-button>
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. </el-form>
  208. </template>
  209. <script>
  210. import costFormAddEdit from "./costFormAddEdit";
  211. import asyncRequest from "@/apis/service/goodStore/goodsOnline";
  212. import showVoucherModel from "@/components/show-voucher-model";
  213. export default {
  214. name: "exam-form",
  215. props: [
  216. "size",
  217. "statusList",
  218. "disabled",
  219. "isMust",
  220. "labelWidth",
  221. "id",
  222. "spuCode",
  223. "sitem",
  224. ],
  225. components: {
  226. costFormAddEdit,
  227. showVoucherModel,
  228. },
  229. /**
  230. * 属性集合
  231. * @param {String} size : 组件大小 非必填
  232. * @param {Array} statusList : 驳回至备选项 必填
  233. * @param {Boolean} disabled : 是否禁用 必填
  234. * @param {Boolean} isMust : 是否需要展示驳回节点 必填
  235. *
  236. *
  237. */
  238. /**
  239. * 事件集合
  240. * @searchChange : 选中值变化调用 抛出选中数据
  241. */
  242. data() {
  243. return {
  244. loading: false,
  245. showVoucher: false,
  246. video_url: "",
  247. img_url: "",
  248. other_url: "",
  249. options: [
  250. {
  251. value: "1",
  252. label: "视频",
  253. },
  254. {
  255. value: "2",
  256. label: "图片",
  257. },
  258. {
  259. value: "3",
  260. label: "其他",
  261. },
  262. ],
  263. showModelThis: this.showModel,
  264. pickerOptions: {
  265. disabledDate(time) {
  266. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  267. },
  268. },
  269. costshowModel: false,
  270. costmodelIndex: "",
  271. costsitem: {},
  272. ruleForm: {
  273. skuCode: "",
  274. proof_type: "1", // 通过or驳回
  275. proof_url: "", //驳回至
  276. good_ladder: [],
  277. },
  278. rulesThis: this.rules,
  279. rules: {
  280. proof_type: [
  281. {
  282. required: true,
  283. message: "请选择审核状态",
  284. trigger: "change",
  285. },
  286. ],
  287. proof_url: [
  288. {
  289. required: true,
  290. message: "请上传凭证文件",
  291. trigger: "blur,change",
  292. },
  293. ],
  294. rebut: [
  295. {
  296. required: true,
  297. message: "请选择驳回节点",
  298. trigger: "change",
  299. },
  300. ],
  301. remark: [
  302. { required: true, message: "请输入审核备注", trigger: "blur" },
  303. {
  304. min: 1,
  305. max: 250,
  306. message: "长度在 1 到 250 个字符",
  307. trigger: "blur",
  308. },
  309. ],
  310. },
  311. };
  312. },
  313. watch: {
  314. isDetail: function (val, old) {
  315. if (this.isDetail !== val) {
  316. this.options = [];
  317. this.selectLoading = false;
  318. }
  319. },
  320. newTime: function (val) {
  321. if (val) {
  322. this.initForm();
  323. }
  324. },
  325. },
  326. mounted() {
  327. this.initForm();
  328. },
  329. methods: {
  330. async initForm() {
  331. console.log(this.spuCode);
  332. this.loading = true;
  333. await this.resetForm();
  334. this.rulesThis = this.rules;
  335. this.loading = false;
  336. },
  337. openCostEdit(index, sitem) {
  338. this.costmodelIndex = index;
  339. this.costsitem = sitem;
  340. this.costshowModel = true;
  341. },
  342. openCostEditDelete(index) {
  343. this.ruleForm.good_ladder.splice(index, 1);
  344. },
  345. //阶梯成本修改
  346. costrefreshEdit(e) {
  347. let item = JSON.parse(JSON.stringify(e));
  348. console.log(item);
  349. const {
  350. index,
  351. id,
  352. min_num,
  353. sale_price,
  354. market_price,
  355. market_platform,
  356. status,
  357. is_del,
  358. } = item;
  359. let ffindex = -1;
  360. this.ruleForm.good_ladder.forEach((i, findex) => {
  361. if (findex === parseInt(index + "")) {
  362. ffindex = findex;
  363. this.ruleForm.good_ladder[findex].id = id;
  364. this.ruleForm.good_ladder[findex].sale_price = sale_price;
  365. this.ruleForm.good_ladder[findex].market_price = market_price;
  366. this.ruleForm.good_ladder[findex].min_num = min_num;
  367. this.ruleForm.good_ladder[findex].market_platform = market_platform;
  368. this.ruleForm.good_ladder[findex].status = status;
  369. this.ruleForm.good_ladder[findex].id_del = is_del;
  370. }
  371. });
  372. if (ffindex === -1) {
  373. this.ruleForm.good_ladder.push(item);
  374. }
  375. this.showModel = false;
  376. },
  377. async resetForm() {
  378. // 重置
  379. await this.$nextTick(() => {
  380. if (this.$refs.ruleForm) {
  381. this.$refs.ruleForm.resetFields();
  382. this.$refs.ruleForm.clearValidate();
  383. const { proof, ladderlist } = this.sitem;
  384. this.ruleForm = {
  385. skuCode: this.id,
  386. proof_type: proof && proof.proof_type ? proof.proof_type : "1", // 通过or驳回
  387. proof_url: proof && proof.proof_url ? proof.proof_url : "", //驳回至
  388. good_ladder:
  389. ladderlist && ladderlist.length > 0
  390. ? JSON.parse(JSON.stringify(ladderlist))
  391. : [],
  392. };
  393. console.log(this.ruleForm.proof_url);
  394. switch (this.ruleForm.proof_type) {
  395. case "1":
  396. this.video_url = this.ruleForm.proof_url;
  397. break;
  398. case "2":
  399. this.img_url = this.ruleForm.proof_url;
  400. break;
  401. case "3":
  402. this.other_url = this.ruleForm.proof_url;
  403. break;
  404. default:
  405. this.video_url = this.ruleForm.proof_url;
  406. }
  407. this.$refs.ruleForm.validateField("proof_url");
  408. }
  409. });
  410. },
  411. async submitForm() {
  412. await this.$refs.ruleForm.validate(async (valid) => {
  413. if (valid) {
  414. let model = JSON.parse(JSON.stringify(this.ruleForm));
  415. let list = JSON.parse(JSON.stringify(model.good_ladder));
  416. let list2 = [];
  417. list.forEach((e) => {
  418. let n = JSON.parse(JSON.stringify(e));
  419. for (let key in n) {
  420. n[key] += "";
  421. }
  422. delete n["index"];
  423. list2.push(n);
  424. });
  425. model.good_ladder = list2;
  426. model.skuCode = this.id;
  427. let res = await asyncRequest.ladderOne(model);
  428. this.loading = false;
  429. if (res && res.code === 0) {
  430. this.$notify.success({
  431. title: "信息提交成功",
  432. message: "",
  433. });
  434. this.$emit("resSuccess", true);
  435. } else if (res && res.code >= 100 && res.code <= 104) {
  436. await this.logout();
  437. } else {
  438. this.$message.warning(res.message);
  439. }
  440. } else {
  441. console.log("error submit!!");
  442. return false;
  443. }
  444. });
  445. },
  446. resvoucher(e) {
  447. const { proof_type, proof_url } = e;
  448. this.ruleForm.proof_type = proof_type || "1";
  449. switch (this.ruleForm.proof_type) {
  450. case "1":
  451. this.video_url = proof_url;
  452. break;
  453. case "2":
  454. this.img_url = proof_url;
  455. break;
  456. case "3":
  457. this.other_url = proof_url;
  458. break;
  459. default:
  460. this.video_url = proof_url;
  461. }
  462. this.set_proof_url();
  463. },
  464. //图片上传成功
  465. async UploadSuccessEventproof_url(data) {
  466. const { url } = data;
  467. if (url === "noToken") {
  468. await this.logout();
  469. } else {
  470. this.img_url = url;
  471. this.set_proof_url();
  472. this.$message.success("图片上传成功!");
  473. }
  474. },
  475. //图片上传失败
  476. UploadErrorEventproof_url(res) {
  477. if (res !== "break") {
  478. this.set_proof_url();
  479. this.$message.error("图片上传失败!");
  480. }
  481. },
  482. //判断图片规格
  483. beforeAvatarUpload(file) {
  484. let isJPG = false;
  485. if (
  486. file.type === "image/jpg" ||
  487. file.type === "image/png" ||
  488. file.type === "image/jpeg"
  489. ) {
  490. isJPG = true;
  491. }
  492. const isLt2M = file.size / 1024 / 1024 < 1;
  493. if (!isJPG) {
  494. this.$message.error("图片格式不正确!");
  495. }
  496. if (!isLt2M) {
  497. this.$message.error("图片大小不能超过 1MB!");
  498. }
  499. return isJPG && isLt2M;
  500. },
  501. //视频上传成功
  502. async UploadSuccessVideoproof_url(data) {
  503. const { url } = data;
  504. if (url === "noToken") {
  505. await this.logout();
  506. } else {
  507. this.video_url = url;
  508. this.set_proof_url();
  509. this.$message.success("视频上传成功!");
  510. }
  511. },
  512. //视频上传失败
  513. UploadErrorVideoproof_url(res) {
  514. if (res !== "break") {
  515. this.set_proof_url();
  516. this.$message.error("视频上传失败!");
  517. }
  518. },
  519. //判断视频规格
  520. beforeVideoUpload(file) {
  521. let isJPG = false;
  522. if (file.type === "video/mp4" || file.type === "video/avi") {
  523. isJPG = true;
  524. }
  525. const isLt2M = file.size / 1024 / 1024 < 10;
  526. if (!isJPG) {
  527. this.$message.error("视频格式不正确!");
  528. }
  529. if (!isLt2M) {
  530. this.$message.error("视频大小不能超过 10MB!");
  531. }
  532. return isJPG && isLt2M;
  533. },
  534. // 其他文件上传成功
  535. async UploadSuccessOtherproof_url(data) {
  536. const { url } = data;
  537. if (url === "noToken") {
  538. await this.logout();
  539. } else {
  540. this.other_url = url;
  541. this.set_proof_url();
  542. this.$message.success("文件成功!");
  543. }
  544. },
  545. //其他文件上传失败
  546. UploadErrorOtherproof_url(res) {
  547. if (res !== "break") {
  548. this.set_proof_url();
  549. this.$message.error("文件上传失败!");
  550. }
  551. },
  552. //判断其他文件规格
  553. beforeOtherUpload(file) {
  554. console.log(file);
  555. let isJPG = false;
  556. if (
  557. file.type === "application/vnd.ms-excel" ||
  558. file.type ===
  559. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
  560. file.type === "application/pdf" ||
  561. file.type === "application/x-zip-compressed"
  562. ) {
  563. isJPG = true;
  564. }
  565. let name = file.name;
  566. let list = name.split(".");
  567. if (list[list.length - 1] === "rar" || list[list.length - 1] === "7z") {
  568. isJPG = true;
  569. }
  570. const isLt2M = file.size / 1024 / 1024 < 5;
  571. if (!isJPG) {
  572. this.$message.error("文件格式不正确!");
  573. }
  574. if (!isLt2M) {
  575. this.$message.error("文件大小不能超过 5MB!");
  576. }
  577. return isJPG && isLt2M;
  578. },
  579. deleteUrl(type) {
  580. switch (type) {
  581. case "1":
  582. this.video_url = "";
  583. break;
  584. case "2":
  585. this.img_url = "";
  586. break;
  587. case "3":
  588. this.other_url = "";
  589. break;
  590. default:
  591. this.video_url = "";
  592. }
  593. this.set_proof_url();
  594. },
  595. set_proof_url() {
  596. const { proof_type } = this.ruleForm;
  597. switch (proof_type) {
  598. case "1":
  599. this.ruleForm.proof_url = this.video_url;
  600. break;
  601. case "2":
  602. this.ruleForm.proof_url = this.img_url;
  603. break;
  604. case "3":
  605. this.ruleForm.proof_url = this.other_url;
  606. break;
  607. default:
  608. this.ruleForm.proof_url = this.video_url;
  609. }
  610. this.$refs.ruleForm.validateField("proof_url");
  611. },
  612. },
  613. };
  614. </script>
  615. <style lang="scss" scoped>
  616. .demo-ruleForm-goodsOnline {
  617. .shangchuan-ul {
  618. li {
  619. position: relative;
  620. width: 100%;
  621. &.tupian {
  622. }
  623. }
  624. }
  625. }
  626. </style>