fixed-price-form.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <template>
  2. <div v-loading="loading">
  3. <el-form
  4. :model="addrForm"
  5. ref="addrForm"
  6. status-icon
  7. class="demo-addrForm-goodsOnline"
  8. :size="'mini'"
  9. >
  10. <el-table
  11. :data="addrForm.good_ladder"
  12. :size="'mini'"
  13. border
  14. stripe
  15. max-height="300px"
  16. row-key="key"
  17. style="width: 100%; margin: 0 0 20px 0"
  18. >
  19. <el-table-column type="index" width="50" show-overflow-tooltip />
  20. <el-table-column
  21. prop="min_num"
  22. label="起订量(>=)"
  23. show-overflow-tooltip
  24. >
  25. <template slot-scope="scope">
  26. <el-form-item
  27. v-show="scope.row.edit"
  28. :prop="'good_ladder.' + scope.$index + '.' + 'min_num'"
  29. :rules="addrRules.min_num"
  30. :size="'mini'"
  31. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  32. >
  33. <digital-input
  34. :values="scope.row.min_num"
  35. :placeholder="'起订量(>=)'"
  36. :min="0"
  37. :max="100000000000"
  38. :position="'right'"
  39. :precision="0"
  40. :controls="false"
  41. :append="''"
  42. :newTime="scope.row.newTime"
  43. :size="'mini'"
  44. :disabled="!scope.row.edit"
  45. @reschange="num_change($event, 'min_num', scope.$index)"
  46. />
  47. </el-form-item>
  48. <span v-show="!scope.row.edit">{{ scope.row.min_num }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="new_sale_price" show-overflow-tooltip>
  52. <template slot="header" slot-scope="scope">
  53. <span>系统售价(元)</span>
  54. <el-popover
  55. placement="top-start"
  56. title="计算公式:"
  57. width="300"
  58. style="margin: 3px 0 0 0"
  59. class="fr"
  60. trigger="hover"
  61. ><div>
  62. <div v-if="sitem.is_gold_price === '1'">
  63. <span class="jiashu">贵金属克重</span>
  64. <span class="jiahao">*</span>
  65. <span class="jiashu">实时金价</span>
  66. <span class="jiahao">+</span>
  67. <span class="jiashu">工艺费</span>
  68. <span class="jiahao">*</span>
  69. <span class="jiashu">贵金属克重</span>
  70. <span class="jiahao">+</span>
  71. </div>
  72. <div>
  73. <span class="jiashu">包装费</span>
  74. <span class="jiahao">+</span>
  75. <span class="jiashu">裸价</span>
  76. <span class="jiahao">+</span>
  77. <span class="jiashu">加标费</span>
  78. <span class="jiahao">+</span>
  79. <span class="jiashu">证书费</span>
  80. <span class="jiahao">+</span>
  81. <span class="jiashu">物流费</span>
  82. </div>
  83. </div>
  84. <i class="el-icon-question tb-icon" slot="reference"></i>
  85. </el-popover>
  86. </template>
  87. <template slot-scope="scope">
  88. <el-form-item
  89. v-show="scope.row.edit"
  90. :prop="'good_ladder.' + scope.$index + '.' + 'new_sale_price'"
  91. :rules="addrRules.new_sale_price"
  92. :size="'mini'"
  93. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  94. >
  95. <el-input
  96. v-loading="scope.row.loading"
  97. v-model="scope.row.new_sale_price"
  98. placeholder="系统售价"
  99. :disabled="true"
  100. :size="'mini'"
  101. maxlength="20"
  102. />
  103. </el-form-item>
  104. <span v-show="!scope.row.edit">{{ scope.row.new_sale_price }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="sale_price" label="售价" show-overflow-tooltip>
  108. <template slot-scope="scope">
  109. <el-form-item
  110. v-show="scope.row.edit"
  111. :prop="'good_ladder.' + scope.$index + '.' + 'sale_price'"
  112. :rules="addrRules.sale_price"
  113. :size="'mini'"
  114. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  115. >
  116. <digital-input
  117. :values="scope.row.sale_price"
  118. :placeholder="'售价'"
  119. :min="0"
  120. :max="100000000000"
  121. :position="'right'"
  122. :precision="2"
  123. :controls="false"
  124. :append="''"
  125. :newTime="scope.row.newTime"
  126. :size="'mini'"
  127. :disabled="!scope.row.edit"
  128. @reschange="num_change($event, 'sale_price', scope.$index)"
  129. />
  130. </el-form-item>
  131. <span v-show="!scope.row.edit">{{ scope.row.sale_price }}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column
  135. prop="market_price"
  136. label="市场价"
  137. show-overflow-tooltip
  138. >
  139. <template slot-scope="scope">
  140. <el-form-item
  141. v-show="scope.row.edit"
  142. :prop="'good_ladder.' + scope.$index + '.' + 'market_price'"
  143. :rules="addrRules.market_price"
  144. :size="'mini'"
  145. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  146. >
  147. <digital-input
  148. :values="scope.row.market_price"
  149. :placeholder="'市场价'"
  150. :min="0"
  151. :max="100000000000"
  152. :position="'right'"
  153. :precision="2"
  154. :controls="false"
  155. :append="''"
  156. :newTime="scope.row.newTime"
  157. :size="'mini'"
  158. :disabled="!scope.row.edit"
  159. @reschange="num_change($event, 'market_price', scope.$index)"
  160. />
  161. </el-form-item>
  162. <span v-show="!scope.row.edit">{{ scope.row.market_price }}</span>
  163. </template>
  164. </el-table-column>
  165. <el-table-column
  166. prop="market_platform"
  167. label="对比平台"
  168. show-overflow-tooltip
  169. >
  170. <template slot-scope="scope">
  171. <el-form-item
  172. v-show="scope.row.edit"
  173. :prop="'good_ladder.' + scope.$index + '.' + 'market_platform'"
  174. :rules="addrRules.market_platform"
  175. :size="'mini'"
  176. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  177. >
  178. <el-input
  179. v-model="scope.row.market_platform"
  180. placeholder="对比平台"
  181. maxlength="50"
  182. :disabled="!scope.row.edit"
  183. />
  184. </el-form-item>
  185. <span v-show="!scope.row.edit">{{
  186. scope.row.market_platform
  187. }}</span>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="status" label="状态" show-overflow-tooltip>
  191. <template slot-scope="scope">
  192. <el-form-item
  193. v-show="scope.row.edit"
  194. :prop="'good_ladder.' + scope.$index + '.' + 'status'"
  195. :rules="addrRules.status"
  196. :size="'mini'"
  197. :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
  198. >
  199. <el-select v-model="scope.row.status" placeholder="状态">
  200. <el-option
  201. v-for="item in status_options"
  202. :key="item.value"
  203. :label="item.label"
  204. :value="item.value"
  205. >
  206. </el-option>
  207. </el-select>
  208. </el-form-item>
  209. <span v-show="!scope.row.edit">{{
  210. scope.row.status == "1" ? "启用" : "禁用"
  211. }}</span>
  212. </template>
  213. </el-table-column>
  214. <el-table-column fixed="right">
  215. <template slot="header" slot-scope="scope">
  216. <span>操作</span>
  217. <el-tooltip effect="dark" content="添加阶梯" placement="top">
  218. <i
  219. class="el-icon-circle-plus-outline tb-icon fr"
  220. @click="openCostEdit(-1)"
  221. ></i>
  222. </el-tooltip>
  223. </template>
  224. <template slot-scope="scope">
  225. <el-tooltip
  226. effect="dark"
  227. content="保存"
  228. v-if="scope.row.edit"
  229. placement="top"
  230. >
  231. <i
  232. class="el-icon-circle-check tb-icon"
  233. @click="checkRow(scope.$index)"
  234. ></i>
  235. </el-tooltip>
  236. <el-tooltip effect="dark" v-else content="修改" placement="top">
  237. <i
  238. class="el-icon-edit tb-icon"
  239. @click="openCostEdit(scope.$index)"
  240. ></i>
  241. </el-tooltip>
  242. <el-tooltip effect="dark" content="删除" placement="top">
  243. <i
  244. class="el-icon-delete tb-icon"
  245. @click="openCostEditDelete(scope.$index)"
  246. ></i>
  247. </el-tooltip>
  248. </template>
  249. </el-table-column>
  250. </el-table>
  251. </el-form>
  252. <el-form
  253. ref="ruleForm"
  254. :model="ruleForm"
  255. status-icon
  256. :rules="rulesThis"
  257. class="demo-ruleForm-goodsOnline"
  258. :size="'mini'"
  259. >
  260. <el-row>
  261. <el-col :span="24"
  262. ><el-form-item label="售价凭证类型" prop="proof_type">
  263. <el-radio-group
  264. v-model="ruleForm.proof_type"
  265. @change="set_proof_url()"
  266. >
  267. <el-radio
  268. v-for="item in options"
  269. :key="item.value"
  270. :label="item.value"
  271. >{{ item.label }}</el-radio
  272. >
  273. </el-radio-group>
  274. <el-button class="fr" type="primary" @click="showVoucher = true"
  275. >查看历史凭证</el-button
  276. >
  277. </el-form-item>
  278. <show-voucher-model
  279. :showModel="showVoucher"
  280. :id="spuCode"
  281. @cancel="showVoucher = false"
  282. @searchChange="resvoucher"
  283. />
  284. </el-col>
  285. <el-col :span="18">
  286. <el-form-item label="凭证文件" prop="proof_url">
  287. <ul class="shangchuan-ul">
  288. <li v-if="ruleForm.proof_type === '1'" class="shiping">
  289. <div v-if="video_url" class="clearfix">
  290. <video width="250" controls class="fl">
  291. <source :src="video_url" type="video/mp4" />
  292. <source :src="video_url" type="video/avi" />
  293. 您的浏览器不支持Video标签。
  294. </video>
  295. <el-link
  296. :underline="false"
  297. @click="deleteUrl('1')"
  298. type="warning"
  299. style="margin: 0 0 0 16px"
  300. >删除</el-link
  301. >
  302. </div>
  303. <div class="activity-upload" v-else>
  304. <div class="btnupload" style="position: relative">
  305. <i class="el-icon-plus avatar-uploader-icon"></i>
  306. <video-upload
  307. class="Upload"
  308. :disabled="type === 'view' || type === 'editCoin'"
  309. :accept="'.mp4,.avi'"
  310. :multiple="false"
  311. :uploadcondition="beforeVideoUpload"
  312. @UploadErrorEvent="UploadVideoEventproof_url"
  313. @UploadSuccessEvent="UploadSuccessVideoproof_url"
  314. />
  315. </div>
  316. <div class="txt-tips fl">
  317. <p>建议大小:小于10MB</p>
  318. <p>文件格式:.mp4,.avi</p>
  319. </div>
  320. </div>
  321. </li>
  322. <li v-if="ruleForm.proof_type === '2'" class="tupian">
  323. <div v-if="img_url" class="clearfix">
  324. <img
  325. style="width: 50px; height: 50px"
  326. :src="img_url"
  327. class="avatar fl"
  328. />
  329. <el-link
  330. :underline="false"
  331. @click="deleteUrl('2')"
  332. type="warning"
  333. style="margin: 0 0 0 16px"
  334. >删除</el-link
  335. >
  336. </div>
  337. <div class="activity-upload" v-else>
  338. <div class="btnupload" style="position: relative">
  339. <i class="el-icon-plus avatar-uploader-icon"></i>
  340. <file-upload
  341. class="Upload"
  342. :disabled="type === 'view' || type === 'editCoin'"
  343. :accept="'.jpg,.png,.jpeg'"
  344. :multiple="false"
  345. :uploadcondition="beforeAvatarUpload"
  346. @UploadErrorEvent="UploadErrorEventproof_url"
  347. @UploadSuccessEvent="UploadSuccessEventproof_url"
  348. ></file-upload>
  349. </div>
  350. <div class="txt-tips fl">
  351. <p>建议大小:小于1MB</p>
  352. <p>文件格式:.jpg,.png,.jpeg</p>
  353. </div>
  354. </div>
  355. </li>
  356. <li v-if="ruleForm.proof_type === '3'" class="qita">
  357. <div v-if="other_url" class="clearfix">
  358. <a :href="other_url" download="凭证文件">点击下载</a>
  359. <el-link
  360. :underline="false"
  361. @click="deleteUrl('3')"
  362. type="warning"
  363. style="margin: 0 0 0 16px"
  364. >删除</el-link
  365. >
  366. </div>
  367. <div class="activity-upload" v-else>
  368. <div class="btnupload" style="position: relative">
  369. <i class="el-icon-plus avatar-uploader-icon"></i>
  370. <file-upload-pdf
  371. class="Upload"
  372. :accept="'.xlsx,.xls,.pdf,.zip,.rar,.7z'"
  373. :multiple="false"
  374. :uploadcondition="beforeOtherUpload"
  375. @UploadErrorEvent="UploadErrorOtherproof_url"
  376. @UploadSuccessEvent="UploadSuccessOtherproof_url"
  377. />
  378. </div>
  379. <div class="txt-tips fl">
  380. <p>建议大小:小于5MB</p>
  381. <p>文件格式:.xlsx,.xls,.pdf,.zip,.rar,.7z</p>
  382. </div>
  383. </div>
  384. </li>
  385. </ul>
  386. </el-form-item>
  387. </el-col>
  388. <el-col :span="6">
  389. <el-form-item class="fr">
  390. <el-button
  391. v-if="!isDetail"
  392. :size="'mini'"
  393. type="primary"
  394. @click="submitForm"
  395. >保 存
  396. </el-button>
  397. </el-form-item>
  398. </el-col>
  399. </el-row>
  400. </el-form>
  401. </div>
  402. </template>
  403. <script>
  404. // import costFormAddEdit from "./costFormAddEdit";
  405. import asyncRequest from "@/apis/service/goodStore/goodsOnline";
  406. import showVoucherModel from "@/components/show-voucher-model";
  407. export default {
  408. name: "exam-form",
  409. props: [
  410. "size",
  411. "statusList",
  412. "disabled",
  413. "isMust",
  414. "labelWidth",
  415. "id",
  416. "spuCode",
  417. "sitem",
  418. ],
  419. components: {
  420. // costFormAddEdit,
  421. showVoucherModel,
  422. },
  423. /**
  424. * 属性集合
  425. * @param {String} size : 组件大小 非必填
  426. * @param {Array} statusList : 驳回至备选项 必填
  427. * @param {Boolean} disabled : 是否禁用 必填
  428. * @param {Boolean} isMust : 是否需要展示驳回节点 必填
  429. *
  430. *
  431. */
  432. /**
  433. * 事件集合
  434. * @searchChange : 选中值变化调用 抛出选中数据
  435. */
  436. data() {
  437. const validate_num = (rule, value, callback) => {
  438. const { required } = rule;
  439. if (required && value === "") {
  440. callback(new Error("不能为空!"));
  441. } else {
  442. callback();
  443. }
  444. };
  445. const validate_num_0 = (rule, value, callback) => {
  446. const { required } = rule;
  447. if (required && value === "") {
  448. callback(new Error("不能为空!"));
  449. } else if (
  450. required &&
  451. (value === "0" ||
  452. value === "0." ||
  453. value === "0.0" ||
  454. value === "0.00" ||
  455. value === "0.000")
  456. ) {
  457. callback(new Error("不能为零!"));
  458. } else {
  459. callback();
  460. }
  461. };
  462. return {
  463. loading: false,
  464. showVoucher: false,
  465. video_url: "",
  466. img_url: "",
  467. other_url: "",
  468. options: [
  469. {
  470. value: "1",
  471. label: "视频",
  472. },
  473. {
  474. value: "2",
  475. label: "图片",
  476. },
  477. {
  478. value: "3",
  479. label: "其他",
  480. },
  481. ],
  482. status_options: [
  483. {
  484. value: "1",
  485. label: "启用",
  486. },
  487. {
  488. value: "0",
  489. label: "禁用",
  490. },
  491. ],
  492. showModelThis: this.showModel,
  493. pickerOptions: {
  494. disabledDate(time) {
  495. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  496. },
  497. },
  498. costshowModel: false,
  499. costmodelIndex: "",
  500. costsitem: {},
  501. ruleForm: {
  502. skuCode: "",
  503. proof_type: "1", // 通过or驳回
  504. proof_url: "", //驳回至
  505. },
  506. rulesThis: this.rules,
  507. rules: {
  508. proof_type: [
  509. {
  510. required: true,
  511. message: "请选择审核状态",
  512. trigger: "change",
  513. },
  514. ],
  515. proof_url: [
  516. {
  517. required: true,
  518. message: "请上传凭证文件",
  519. trigger: "blur,change",
  520. },
  521. ],
  522. rebut: [
  523. {
  524. required: true,
  525. message: "请选择驳回节点",
  526. trigger: "change",
  527. },
  528. ],
  529. remark: [
  530. { required: true, message: "请输入审核备注", trigger: "blur" },
  531. {
  532. min: 1,
  533. max: 250,
  534. message: "长度在 1 到 250 个字符",
  535. trigger: "blur",
  536. },
  537. ],
  538. },
  539. addrForm: {
  540. good_ladder: [],
  541. },
  542. addrRules: {
  543. min_num: [
  544. {
  545. required: true,
  546. validator: validate_num_0,
  547. trigger: "blur",
  548. },
  549. ],
  550. sale_price: [
  551. {
  552. required: true,
  553. trigger: "blur",
  554. validator: validate_num,
  555. },
  556. ],
  557. market_price: [
  558. {
  559. required: true,
  560. validator: validate_num,
  561. trigger: "blur",
  562. },
  563. ],
  564. market_platform: [
  565. {
  566. required: true,
  567. message: "对比平台不能为空",
  568. trigger: "blur",
  569. },
  570. ],
  571. status: [
  572. {
  573. required: true,
  574. message: "状态不能为空",
  575. trigger: "change",
  576. },
  577. ],
  578. },
  579. };
  580. },
  581. watch: {
  582. isDetail: function (val, old) {
  583. if (this.isDetail !== val) {
  584. this.options = [];
  585. this.selectLoading = false;
  586. }
  587. },
  588. newTime: function (val) {
  589. if (val) {
  590. this.initForm();
  591. }
  592. },
  593. },
  594. mounted() {
  595. this.initForm();
  596. },
  597. methods: {
  598. async initForm() {
  599. console.log(this.spuCode);
  600. this.loading = true;
  601. await this.resetForm();
  602. this.rulesThis = this.rules;
  603. this.loading = false;
  604. },
  605. openCostEdit(index) {
  606. let findex = this.addrForm.good_ladder.findIndex((v) => v.edit === true);
  607. if (findex !== -1) {
  608. this.$message.warning("当前已有阶梯售价在编辑,请保存后再试!");
  609. return;
  610. } else {
  611. if (index === -1) {
  612. this.addrForm.good_ladder.push({
  613. edit: true,
  614. min_num: "",
  615. new_sale_price: "",
  616. sale_price: "",
  617. market_price: "",
  618. market_platform: "",
  619. status: "1",
  620. });
  621. } else {
  622. this.addrForm.good_ladder[index].edit = true;
  623. this.addrForm.good_ladder[index].newTime = new Date().valueOf() + "";
  624. }
  625. }
  626. },
  627. async get_new(index) {
  628. const { min_num } = this.addrForm.good_ladder[index];
  629. this.addrForm.good_ladder[index].search_loading = true;
  630. let { code, data, message } = await asyncRequest.goodupprice({
  631. min_num: min_num,
  632. spuCode: this.spuCode,
  633. });
  634. let resModel = {
  635. isok: code,
  636. price: code === 0 ? data.sale_price : "0",
  637. message: message,
  638. };
  639. this.addrForm.good_ladder[index].search_loading = false;
  640. return resModel;
  641. },
  642. //保存某一行
  643. async checkRow(rowIndex) {
  644. await this.$refs.addrForm.validate(async (valid) => {
  645. if (valid) {
  646. if (!this.addrForm.good_ladder[rowIndex].search_loading) {
  647. const { min_num } = this.addrForm.good_ladder[rowIndex];
  648. let findex = this.addrForm.good_ladder.findIndex(
  649. (v) => v.edit !== true && v.min_num + "" === min_num + ""
  650. );
  651. if (findex !== -1) {
  652. this.$message.warning("当前已有相同起订量的销售价!");
  653. return;
  654. }
  655. let { isok, price, message } = await this.get_new(rowIndex);
  656. if (isok === 0) {
  657. this.addrForm.good_ladder[rowIndex].new_sale_price = price;
  658. this.addrForm.good_ladder[rowIndex].edit = false;
  659. } else if (isok >= 100 && isok <= 104) {
  660. await this.logout();
  661. } else {
  662. this.addrForm.good_ladder[rowIndex].new_sale_price = price;
  663. this.$message.warning(message);
  664. }
  665. }
  666. } else {
  667. console.log("error submit!!");
  668. return false;
  669. }
  670. });
  671. },
  672. openCostEditDelete(index) {
  673. this.addrForm.good_ladder.splice(index, 1);
  674. },
  675. async num_change(e, key, index) {
  676. this.addrForm.good_ladder[index][key] = e + "" || "0";
  677. if (key === "min_num") {
  678. const { min_num } = this.addrForm.good_ladder[index];
  679. if (min_num === "" || min_num === "0") {
  680. this.addrForm.good_ladder[index].new_sale_price = "0";
  681. } else {
  682. if (!this.addrForm.good_ladder[index].search_loading) {
  683. let { isok, price, message } = await this.get_new(index);
  684. if (isok === 0) {
  685. this.addrForm.good_ladder[index].new_sale_price = price;
  686. } else if (isok >= 100 && isok <= 104) {
  687. await this.logout();
  688. } else {
  689. this.addrForm.good_ladder[index].new_sale_price = price;
  690. this.$message.warning(message);
  691. }
  692. }
  693. }
  694. }
  695. },
  696. async resetForm() {
  697. // 重置
  698. await this.$nextTick(async () => {
  699. if (this.$refs.ruleForm && this.$refs.addrForm) {
  700. this.$refs.ruleForm.resetFields();
  701. this.$refs.ruleForm.clearValidate();
  702. this.$refs.addrForm.resetFields();
  703. this.$refs.addrForm.clearValidate();
  704. let { proof, ladderlist } = this.sitem;
  705. ladderlist.map((a) => {
  706. a.search_loading = false;
  707. a.new_sale_price = "0";
  708. a.newTime = new Date().valueOf() + "";
  709. a.edit = false;
  710. return a;
  711. });
  712. this.ruleForm = {
  713. skuCode: this.id,
  714. proof_type: proof && proof.proof_type ? proof.proof_type : "1", // 通过or驳回
  715. proof_url: proof && proof.proof_url ? proof.proof_url : "", //驳回至
  716. };
  717. this.addrForm = {
  718. good_ladder:
  719. ladderlist && ladderlist.length > 0
  720. ? JSON.parse(JSON.stringify(ladderlist))
  721. : [],
  722. };
  723. // console.log(this.ruleForm.proof_url);
  724. switch (this.ruleForm.proof_type) {
  725. case "1":
  726. this.video_url = this.ruleForm.proof_url;
  727. break;
  728. case "2":
  729. this.img_url = this.ruleForm.proof_url;
  730. break;
  731. case "3":
  732. this.other_url = this.ruleForm.proof_url;
  733. break;
  734. default:
  735. this.video_url = this.ruleForm.proof_url;
  736. }
  737. this.$refs.ruleForm.validateField("proof_url");
  738. for (let i = 0; i < this.addrForm.good_ladder.length; i++) {
  739. let { isok, price, message } = await this.get_new(i);
  740. if (isok === 0) {
  741. this.addrForm.good_ladder[i].new_sale_price = price;
  742. this.addrForm.good_ladder[i].edit = false;
  743. } else if (isok >= 100 && isok <= 104) {
  744. await this.logout();
  745. } else {
  746. this.addrForm.good_ladder[i].new_sale_price = price;
  747. this.addrForm.good_ladder[i].edit = true;
  748. this.addrForm.good_ladder[i].newTime = new Date().valueOf() + "";
  749. this.$message.warning(message);
  750. }
  751. }
  752. }
  753. });
  754. },
  755. async submitForm() {
  756. await this.$refs.ruleForm.validate(async (valid) => {
  757. if (valid) {
  758. this.loading = true;
  759. let model = JSON.parse(JSON.stringify(this.ruleForm));
  760. if (this.addrForm.good_ladder.length === 0) {
  761. this.$message.warning("至少添加一条销售价信息!");
  762. this.loading = false;
  763. return;
  764. }
  765. let list = JSON.parse(JSON.stringify(this.addrForm.good_ladder));
  766. let isedit = false;
  767. list.forEach((v) => {
  768. if (v.edit) {
  769. isedit = true;
  770. }
  771. });
  772. if (isedit) {
  773. this.$message.warning("请保存阶梯售价!");
  774. this.loading = false;
  775. return;
  776. }
  777. let all_is_ok = true;
  778. for (let i = 0; i < this.addrForm.good_ladder; i++) {
  779. this.addrForm.good_ladder[i].search_loading = true;
  780. let { isok, price } = await this.get_new(i);
  781. if (isok === 0) {
  782. this.addrForm.good_ladder[i].new_sale_price = price;
  783. this.addrForm.good_ladder[i].edit = false;
  784. } else if (isok >= 100 && isok <= 104) {
  785. await this.logout();
  786. } else {
  787. all_is_ok = false;
  788. this.addrForm.good_ladder[i].new_sale_price = price;
  789. this.addrForm.good_ladder[i].edit = true;
  790. this.addrForm.good_ladder[i].newTime = new Date().valueOf() + "";
  791. }
  792. }
  793. if (!all_is_ok) {
  794. this.$message.warning("阶梯售价未满足成本最低起订量!");
  795. this.loading = false;
  796. }
  797. let list2 = [];
  798. list.forEach((e) => {
  799. let n = JSON.parse(JSON.stringify(e));
  800. for (let key in n) {
  801. n[key] += "";
  802. }
  803. delete n["index"];
  804. list2.push(n);
  805. });
  806. model.good_ladder = list2;
  807. model.skuCode = this.id;
  808. let res = await asyncRequest.ladderOne(model);
  809. this.loading = false;
  810. if (res && res.code === 0) {
  811. this.$notify.success({
  812. title: "信息提交成功",
  813. message: "",
  814. });
  815. this.$emit("resSuccess", true);
  816. } else if (res && res.code >= 100 && res.code <= 104) {
  817. await this.logout();
  818. } else {
  819. this.$message.warning(res.message);
  820. }
  821. } else {
  822. console.log("error submit!!");
  823. return false;
  824. }
  825. });
  826. },
  827. resvoucher(e) {
  828. const { proof_type, proof_url } = e;
  829. this.ruleForm.proof_type = proof_type || "1";
  830. switch (this.ruleForm.proof_type) {
  831. case "1":
  832. this.video_url = proof_url;
  833. break;
  834. case "2":
  835. this.img_url = proof_url;
  836. break;
  837. case "3":
  838. this.other_url = proof_url;
  839. break;
  840. default:
  841. this.video_url = proof_url;
  842. }
  843. this.set_proof_url();
  844. },
  845. //图片上传成功
  846. async UploadSuccessEventproof_url(data) {
  847. const { url } = data;
  848. if (url === "noToken") {
  849. await this.logout();
  850. } else {
  851. this.img_url = url;
  852. this.set_proof_url();
  853. this.$message.success("图片上传成功!");
  854. }
  855. },
  856. //图片上传失败
  857. UploadErrorEventproof_url(res) {
  858. if (res !== "break") {
  859. this.set_proof_url();
  860. this.$message.error("图片上传失败!");
  861. }
  862. },
  863. //判断图片规格
  864. beforeAvatarUpload(file) {
  865. let isJPG = false;
  866. if (
  867. file.type === "image/jpg" ||
  868. file.type === "image/png" ||
  869. file.type === "image/jpeg"
  870. ) {
  871. isJPG = true;
  872. }
  873. const isLt2M = file.size / 1024 / 1024 < 1;
  874. if (!isJPG) {
  875. this.$message.error("图片格式不正确!");
  876. }
  877. if (!isLt2M) {
  878. this.$message.error("图片大小不能超过 1MB!");
  879. }
  880. return isJPG && isLt2M;
  881. },
  882. //视频上传成功
  883. async UploadSuccessVideoproof_url(data) {
  884. const { url } = data;
  885. if (url === "noToken") {
  886. await this.logout();
  887. } else {
  888. this.video_url = url;
  889. this.set_proof_url();
  890. this.$message.success("视频上传成功!");
  891. }
  892. },
  893. //视频上传失败
  894. UploadErrorVideoproof_url(res) {
  895. if (res !== "break") {
  896. this.set_proof_url();
  897. this.$message.error("视频上传失败!");
  898. }
  899. },
  900. //判断视频规格
  901. beforeVideoUpload(file) {
  902. let isJPG = false;
  903. if (file.type === "video/mp4" || file.type === "video/avi") {
  904. isJPG = true;
  905. }
  906. const isLt2M = file.size / 1024 / 1024 < 10;
  907. if (!isJPG) {
  908. this.$message.error("视频格式不正确!");
  909. }
  910. if (!isLt2M) {
  911. this.$message.error("视频大小不能超过 10MB!");
  912. }
  913. return isJPG && isLt2M;
  914. },
  915. // 其他文件上传成功
  916. async UploadSuccessOtherproof_url(data) {
  917. const { url } = data;
  918. if (url === "noToken") {
  919. await this.logout();
  920. } else {
  921. this.other_url = url;
  922. this.set_proof_url();
  923. this.$message.success("文件成功!");
  924. }
  925. },
  926. //其他文件上传失败
  927. UploadErrorOtherproof_url(res) {
  928. if (res !== "break") {
  929. this.set_proof_url();
  930. this.$message.error("文件上传失败!");
  931. }
  932. },
  933. //判断其他文件规格
  934. beforeOtherUpload(file) {
  935. console.log(file);
  936. let isJPG = false;
  937. if (
  938. file.type === "application/vnd.ms-excel" ||
  939. file.type ===
  940. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
  941. file.type === "application/pdf" ||
  942. file.type === "application/x-zip-compressed"
  943. ) {
  944. isJPG = true;
  945. }
  946. let name = file.name;
  947. let list = name.split(".");
  948. if (list[list.length - 1] === "rar" || list[list.length - 1] === "7z") {
  949. isJPG = true;
  950. }
  951. const isLt2M = file.size / 1024 / 1024 < 5;
  952. if (!isJPG) {
  953. this.$message.error("文件格式不正确!");
  954. }
  955. if (!isLt2M) {
  956. this.$message.error("文件大小不能超过 5MB!");
  957. }
  958. return isJPG && isLt2M;
  959. },
  960. deleteUrl(type) {
  961. switch (type) {
  962. case "1":
  963. this.video_url = "";
  964. break;
  965. case "2":
  966. this.img_url = "";
  967. break;
  968. case "3":
  969. this.other_url = "";
  970. break;
  971. default:
  972. this.video_url = "";
  973. }
  974. this.set_proof_url();
  975. },
  976. set_proof_url() {
  977. const { proof_type } = this.ruleForm;
  978. switch (proof_type) {
  979. case "1":
  980. this.ruleForm.proof_url = this.video_url;
  981. break;
  982. case "2":
  983. this.ruleForm.proof_url = this.img_url;
  984. break;
  985. case "3":
  986. this.ruleForm.proof_url = this.other_url;
  987. break;
  988. default:
  989. this.ruleForm.proof_url = this.video_url;
  990. }
  991. this.$refs.ruleForm.validateField("proof_url");
  992. },
  993. },
  994. };
  995. </script>
  996. <style lang="scss" scoped>
  997. .demo-ruleForm-goodsOnline {
  998. .shangchuan-ul {
  999. li {
  1000. position: relative;
  1001. width: 100%;
  1002. &.tupian {
  1003. }
  1004. }
  1005. }
  1006. }
  1007. </style>