baseForm.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. <template>
  2. <el-form
  3. ref="ruleForm"
  4. v-loading="loading"
  5. :model="ruleForm"
  6. status-icon
  7. :rules="rulesThis"
  8. :size="'small'"
  9. label-width="100px"
  10. class="supplierAdd"
  11. >
  12. <el-row>
  13. <el-col :span="6">
  14. <div class="supplierAdd-title" style="margin: 6px 0 0 10px">
  15. 基础信息
  16. </div></el-col
  17. >
  18. <el-col :span="6">
  19. <el-form-item label="合作状态" prop="coop_state">
  20. <el-select
  21. style="width: 100%"
  22. v-model="ruleForm.coop_state"
  23. :disabled="type !== 'add' && type !== 'edit'"
  24. placeholder="合作状态"
  25. >
  26. <el-option
  27. v-for="item in coop_stateoptions"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value"
  31. >
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="6">
  37. <el-form-item label="供应商来源" prop="source">
  38. <el-select
  39. style="width: 100%"
  40. v-model="ruleForm.source"
  41. :disabled="type !== 'add' && type !== 'edit'"
  42. placeholder="供应商来源"
  43. >
  44. <el-option
  45. v-for="item in sourceoptions"
  46. :key="item.value"
  47. :label="item.label"
  48. :value="item.value"
  49. >
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="6">
  55. <el-form-item label="申请类型" prop="type">
  56. <el-select
  57. style="width: 100%"
  58. v-model="ruleForm.type"
  59. :disabled="type !== 'add' && type !== 'edit'"
  60. placeholder="申请类型"
  61. >
  62. <el-option
  63. v-for="item in typeoptions"
  64. :key="item.value"
  65. :label="item.label"
  66. :value="item.value"
  67. >
  68. </el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="6">
  73. <el-form-item label="所属类别" prop="category">
  74. <el-select
  75. style="width: 100%"
  76. v-model="ruleForm.category"
  77. :disabled="type !== 'add' && type !== 'edit'"
  78. placeholder="所属类别"
  79. >
  80. <el-option
  81. v-for="item in categoryoptions"
  82. :key="item.value"
  83. :label="item.label"
  84. :value="item.value"
  85. >
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="6">
  91. <el-form-item label="物流方式" prop="delivery_way">
  92. <el-select
  93. style="width: 100%"
  94. v-model="ruleForm.delivery_way"
  95. :disabled="type !== 'add' && type !== 'edit'"
  96. placeholder="物流方式"
  97. >
  98. <el-option
  99. v-for="item in delivery_wayoptions"
  100. :key="item.value"
  101. :label="item.label"
  102. :value="item.value"
  103. >
  104. </el-option>
  105. </el-select> </el-form-item
  106. ></el-col>
  107. <el-col :span="6"
  108. ><el-form-item label="供应商类型" prop="supplier_type">
  109. <el-select
  110. style="width: 100%"
  111. v-model="ruleForm.supplier_type"
  112. :disabled="type !== 'add' && type !== 'edit'"
  113. placeholder="供应商类型"
  114. >
  115. <el-option
  116. v-for="item in supplier_typeoptions"
  117. :key="item.value"
  118. :label="item.label"
  119. :value="item.value"
  120. >
  121. </el-option>
  122. </el-select> </el-form-item
  123. ></el-col>
  124. <el-col :span="6">
  125. <el-form-item label="供应商级别" prop="level">
  126. <el-select
  127. style="width: 100%"
  128. v-model="ruleForm.level"
  129. :disabled="type !== 'add' && type !== 'edit'"
  130. placeholder="供应商级别"
  131. >
  132. <el-option
  133. v-for="item in leveloptions"
  134. :key="item.value"
  135. :label="item.label"
  136. :value="item.value"
  137. >
  138. </el-option>
  139. </el-select>
  140. </el-form-item>
  141. </el-col>
  142. <el-col :span="6">
  143. <el-form-item label="付款方式" prop="pay_type">
  144. <el-select
  145. style="width: 100%"
  146. v-model="ruleForm.pay_type"
  147. :disabled="type !== 'add' && type !== 'edit'"
  148. placeholder="付款方式"
  149. >
  150. <el-option
  151. v-for="item in pay_typeoptions"
  152. :key="item.value"
  153. :label="item.label"
  154. :value="item.value"
  155. >
  156. </el-option>
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="负责人" prop="personid">
  160. <search-account
  161. :disabled="type !== 'add' && type !== 'edit'"
  162. :is-detail="type !== 'add'"
  163. :value="ruleForm.personid"
  164. :size="'small'"
  165. :names="hand_name"
  166. :placeholder="'负责人名称'"
  167. @searchChange="handleHandoverName"
  168. />
  169. </el-form-item>
  170. </el-col>
  171. <el-col :span="6">
  172. <el-form-item
  173. label="营业执照"
  174. prop="supplier_img"
  175. :disabled="id == 'view'"
  176. class="activity-upload"
  177. >
  178. <div v-if="ruleForm.supplier_img" class="img-find">
  179. <img
  180. :src="ruleForm.supplier_img"
  181. class="avatar hover fl"
  182. v-viewer
  183. style="width: 84px; height: 84px"
  184. />
  185. <el-link
  186. class="fl"
  187. v-if="type !== 'view'"
  188. :underline="false"
  189. @click="deleteimg()"
  190. type="warning"
  191. style="margin: 0 0 0 16px"
  192. >删除</el-link
  193. >
  194. </div>
  195. <div class="btnupload" style="position: relative" v-else>
  196. <i class="el-icon-plus avatar-uploader-icon"></i>
  197. <file-upload
  198. v-if="type !== 'view'"
  199. class="Upload"
  200. :disabled="id == 'view'"
  201. :accept="'.jpg,.png,.jpeg'"
  202. :multiple="true"
  203. :uploadcondition="beforeAvatarUpload"
  204. @UploadErrorEvent="UploadErrorEventsupplier_img"
  205. @UploadSuccessEvent="UploadSuccessEventsupplier_img"
  206. ></file-upload>
  207. </div>
  208. </el-form-item>
  209. </el-col>
  210. <el-col :span="12">
  211. <el-form-item label="资质证明" prop="prove_img">
  212. <div class="good_info_img_div">
  213. <ul class="clear">
  214. <template
  215. v-if="
  216. ruleForm &&
  217. ruleForm.prove_img &&
  218. ruleForm.prove_img.length > 0
  219. "
  220. >
  221. <li
  222. class="img-show-li"
  223. v-viewer
  224. v-for="(img, iindex) in ruleForm.prove_img"
  225. :key="img + iindex"
  226. >
  227. <div class="img-show-li-div">
  228. <img :src="img" class="img-show" alt="" />
  229. <i
  230. v-if="type === 'add' || type === 'edit'"
  231. class="el-icon-close"
  232. @click="closeImg(iindex)"
  233. ></i>
  234. </div>
  235. </li>
  236. </template>
  237. <li
  238. class="img-show-li"
  239. v-if="
  240. ruleForm &&
  241. ruleForm.prove_img &&
  242. ruleForm.prove_img.length < 10 &&
  243. type !== 'view'
  244. "
  245. >
  246. <div class="activity-upload">
  247. <div class="btnupload" style="position: relative">
  248. <i class="el-icon-plus avatar-uploader-icon"></i>
  249. <file-upload
  250. class="Upload"
  251. :disabled="type !== 'add' && type !== 'edit'"
  252. :accept="'.jpg,.png,.jpeg'"
  253. :multiple="true"
  254. :uploadcondition="beforeAvatarUpload"
  255. @UploadErrorEvent="UploadErrorEventgood_info_img"
  256. @UploadSuccessEvent="UploadSuccessEventgood_info_img"
  257. ></file-upload>
  258. </div>
  259. </div>
  260. </li>
  261. </ul>
  262. </div>
  263. </el-form-item>
  264. </el-col>
  265. <el-col :span="24"
  266. ><div class="supplierAdd-title">联系人信息</div></el-col
  267. >
  268. <el-col :span="6">
  269. <el-form-item label="姓名" prop="contactor">
  270. <el-input
  271. v-model="ruleForm.contactor"
  272. :disabled="type !== 'add' && type !== 'edit'"
  273. placeholder="姓名"
  274. maxlength="20"
  275. />
  276. </el-form-item>
  277. </el-col>
  278. <el-col :span="6">
  279. <el-form-item label="手机号" prop="mobile">
  280. <el-input
  281. v-model="ruleForm.mobile"
  282. :disabled="type !== 'add' && type !== 'edit'"
  283. placeholder="手机号"
  284. maxlength="20"
  285. />
  286. </el-form-item>
  287. </el-col>
  288. <el-col :span="6">
  289. <el-form-item label="座机号" prop="telephone">
  290. <el-input
  291. v-model="ruleForm.telephone"
  292. :disabled="type !== 'add' && type !== 'edit'"
  293. placeholder="座机号"
  294. maxlength="20"
  295. />
  296. </el-form-item>
  297. </el-col>
  298. <el-col :span="6">
  299. <el-form-item label="职位" prop="position">
  300. <el-input
  301. v-model="ruleForm.position"
  302. :disabled="type !== 'add' && type !== 'edit'"
  303. placeholder="职位"
  304. maxlength="20"
  305. />
  306. </el-form-item>
  307. </el-col>
  308. <el-col :span="24">
  309. <div class="supplierAdd-title">营业执照信息</div></el-col
  310. >
  311. <el-col :span="16">
  312. <el-form-item label="供应商名称" prop="name">
  313. <el-input
  314. v-model="ruleForm.name"
  315. :disabled="type !== 'add' && type !== 'edit'"
  316. placeholder="供应商名称"
  317. maxlength="20"
  318. />
  319. </el-form-item>
  320. </el-col>
  321. <el-col :span="8" v-if="!(ruleForm.supplier_img && type === 'add')">
  322. <el-form-item
  323. label="统一社会信用代码"
  324. prop="registercode"
  325. label-width="140px"
  326. >
  327. <el-input
  328. v-model="ruleForm.registercode"
  329. :disabled="
  330. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  331. (type !== 'add' && type !== 'edit')
  332. "
  333. placeholder="统一社会信用代码"
  334. maxlength="20"
  335. />
  336. </el-form-item>
  337. </el-col>
  338. <el-col :span="16" v-if="!(ruleForm.supplier_img && type === 'add')">
  339. <el-form-item label="详细地址" prop="addr">
  340. <el-input
  341. v-model="ruleForm.addr"
  342. :disabled="
  343. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  344. (type !== 'add' && type !== 'edit')
  345. "
  346. placeholder="详细地址"
  347. maxlength="20"
  348. />
  349. </el-form-item>
  350. </el-col>
  351. <el-col :span="8" v-if="!(ruleForm.supplier_img && type === 'add')">
  352. <el-form-item label="公司类型" prop="nature">
  353. <search-company-type
  354. :value="ruleForm.nature"
  355. :disabled="
  356. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  357. (type !== 'add' && type !== 'edit')
  358. "
  359. :size="'small'"
  360. :isDetail="false"
  361. :placeholder="'公司类型'"
  362. @searchChange="type_search_change"
  363. />
  364. </el-form-item>
  365. </el-col>
  366. <el-col :span="16" v-if="!(ruleForm.supplier_img && type === 'add')">
  367. <el-form-item label="运营范围" prop="scope">
  368. <el-input
  369. v-model="ruleForm.scope"
  370. :autosize="{ minRows: 4, maxRows: 4 }"
  371. type="textarea"
  372. :disabled="
  373. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  374. (type !== 'add' && type !== 'edit')
  375. "
  376. placeholder="运营范围"
  377. maxlength="20"
  378. />
  379. </el-form-item>
  380. </el-col>
  381. <el-col :span="8" v-if="!(ruleForm.supplier_img && type === 'add')">
  382. <el-form-item label="法人代表" prop="legaler">
  383. <el-input
  384. v-model="ruleForm.legaler"
  385. :disabled="
  386. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  387. (type !== 'add' && type !== 'edit')
  388. "
  389. placeholder="法人代表"
  390. maxlength="20"
  391. />
  392. </el-form-item>
  393. <el-form-item label="成立日期" prop="registertime">
  394. <el-date-picker
  395. v-model="ruleForm.registertime"
  396. type="date"
  397. value-format="yyyy-MM-dd"
  398. :disabled="
  399. (ruleForm.supplier_img && (type == 'add' || type == 'edit')) ||
  400. (type !== 'add' && type !== 'edit')
  401. "
  402. style="width: 100%"
  403. :picker-options="pickerOptions"
  404. placeholder="成立日期"
  405. >
  406. </el-date-picker>
  407. </el-form-item>
  408. </el-col>
  409. <el-col
  410. :span="24"
  411. style="text-align: right"
  412. v-if="type === 'add' || type === 'edit'"
  413. >
  414. <el-button type="primary" :size="'small'" @click="submitForm"
  415. >保 存
  416. </el-button>
  417. </el-col>
  418. </el-row>
  419. </el-form>
  420. </template>
  421. <script>
  422. import asyncRequest from "@/apis/service/serviceParam/supplier";
  423. import resToken from "@/mixins/resToken";
  424. import { isLicense, isMobile, isqz } from "@/utils/validate";
  425. export default {
  426. name: "supplierAdd",
  427. mixins: [resToken],
  428. props: ["showModel", "id", "type", "sitem"],
  429. data() {
  430. const validateLicense = (rule, value, callback) => {
  431. if (value !== "") {
  432. if (!isLicense(value)) {
  433. callback(new Error("统一社会信用代码不正确!"));
  434. } else {
  435. callback();
  436. }
  437. } else {
  438. callback(new Error("请输入统一社会信用代码!"));
  439. }
  440. };
  441. const validatemobile = (rule, value, callback) => {
  442. if (value === "") {
  443. callback(new Error("手机号不能为空!"));
  444. } else {
  445. if (!isMobile(value)) {
  446. callback(new Error("手机号格式不正确!"));
  447. } else {
  448. callback();
  449. }
  450. }
  451. };
  452. const validatetelephone = (rule, value, callback) => {
  453. if (value === "") {
  454. callback();
  455. } else {
  456. if (isqz(value)) {
  457. callback();
  458. } else {
  459. callback(new Error("规则为区号[0+2~3位]-固定电话[7~8位]!"));
  460. }
  461. }
  462. };
  463. return {
  464. loading: false,
  465. hand_name: "",
  466. coop_stateoptions: [
  467. { value: "0", label: "白名单" },
  468. { value: "1", label: "黑名单" },
  469. ],
  470. sourceoptions: [
  471. { value: "0", label: "客户提供" },
  472. { value: "1", label: "供应商" },
  473. { value: "2", label: "公司开发" },
  474. ],
  475. typeoptions: [
  476. { value: "0", label: "正式供应商" },
  477. { value: "1", label: "临时供应商" },
  478. ],
  479. categoryoptions: [
  480. { value: "0", label: "单品类供应商" },
  481. { value: "1", label: "多品类供应商" },
  482. ],
  483. delivery_wayoptions: [
  484. { value: "0", label: "供应商发货" },
  485. { value: "1", label: "公司自提" },
  486. ],
  487. supplier_typeoptions: [
  488. { value: "0", label: "生产厂家" },
  489. { value: "1", label: "代理商" },
  490. { value: "2", label: "经销商" },
  491. { value: "3", label: "分销商" },
  492. { value: "4", label: "电商平台" },
  493. ],
  494. leveloptions: [
  495. { value: "2", label: "生产厂家" },
  496. { value: "0", label: "一级代理商" },
  497. { value: "1", label: "二级代理商" },
  498. ],
  499. pay_typeoptions: [
  500. { value: "0", label: "现结" },
  501. { value: "1", label: "月清" },
  502. { value: "2", label: "双月清" },
  503. ],
  504. ocr_status: [
  505. { id: "0", label: "未上传" },
  506. { id: "1", label: "识别成功" },
  507. { id: "2", label: "识别失败" },
  508. ],
  509. title: "添加供应商",
  510. showModelThis: this.showModel,
  511. pickerOptions: {
  512. disabledDate(time) {
  513. return time.getTime() > Date.now();
  514. },
  515. },
  516. ruleForm: {},
  517. rulesThis: this.rules,
  518. rules: {
  519. coop_state: [
  520. { required: true, message: "请选择合作状态", trigger: "change" },
  521. ],
  522. source: [
  523. { required: true, message: "请选择供应商来源", trigger: "change" },
  524. ],
  525. type: [
  526. { required: true, message: "请选择申请类型", trigger: "change" },
  527. ],
  528. category: [
  529. { required: true, message: "请选择所属类别", trigger: "change" },
  530. ],
  531. delivery_way: [
  532. { required: true, message: "请选择物流方式", trigger: "change" },
  533. ],
  534. supplier_type: [
  535. { required: true, message: "请选择供应商类型", trigger: "change" },
  536. ],
  537. level: [
  538. { required: true, message: "请选择供应商级别", trigger: "change" },
  539. ],
  540. pay_type: [
  541. { required: true, message: "请选择付款方式", trigger: "change" },
  542. ],
  543. prove_img: [
  544. {
  545. required: false,
  546. type: "array",
  547. message: "请上传资质证明",
  548. trigger: "change",
  549. },
  550. ],
  551. personid: [
  552. {
  553. required: true,
  554. type: "array",
  555. message: "请选择负责人",
  556. trigger: "change",
  557. },
  558. ],
  559. contactor: [
  560. { required: true, message: "姓名不能为空", trigger: "blur" },
  561. ],
  562. mobile: [
  563. { required: true, validator: validatemobile, trigger: "blur" },
  564. ],
  565. telephone: [
  566. { required: false, validator: validatetelephone, trigger: "blur" },
  567. ],
  568. position: [
  569. { required: true, message: "职位不能为空", trigger: "blur" },
  570. ],
  571. registercode: [
  572. { required: true, validator: validateLicense, trigger: "blur" },
  573. ],
  574. name: [
  575. { required: true, message: "供应商名称不能为空", trigger: "blur" },
  576. ],
  577. nature: [
  578. { required: true, message: "公司类型不能为空", trigger: "change" },
  579. ],
  580. addr: [
  581. { required: true, message: "详细地址不能为空", trigger: "blur" },
  582. ],
  583. legaler: [
  584. { required: true, message: "法人代表不能为空", trigger: "blur" },
  585. ],
  586. registertime: [
  587. { required: true, message: "成立时间不能为空", trigger: "change" },
  588. ],
  589. scope: [
  590. { required: true, message: "营业执照不能为空", trigger: "blur" },
  591. ],
  592. },
  593. };
  594. },
  595. mounted() {
  596. this.initForm();
  597. },
  598. methods: {
  599. async initForm() {
  600. this.hand_name = "";
  601. this.loading = true;
  602. this.resetFormData();
  603. this.rulesThis = this.rules;
  604. await this.resetForm();
  605. this.loading = false;
  606. },
  607. async resetForm() {
  608. // 重置
  609. await this.$nextTick(() => {
  610. if (this.$refs.ruleForm) {
  611. this.$refs.ruleForm.resetFields();
  612. this.$refs.ruleForm.clearValidate();
  613. this.resetFormData();
  614. }
  615. });
  616. },
  617. resetFormData() {
  618. const {
  619. id,
  620. coop_state,
  621. source,
  622. type,
  623. category,
  624. delivery_way,
  625. supplier_type,
  626. level,
  627. pay_type,
  628. supplier_img,
  629. prove_img,
  630. contactor,
  631. mobile,
  632. position,
  633. registercode,
  634. name,
  635. nature,
  636. addr,
  637. legaler,
  638. registertime,
  639. scope,
  640. personid,
  641. person,
  642. telephone,
  643. } = this.sitem;
  644. this.hand_name = person || "";
  645. this.ruleForm = {
  646. id: id || "",
  647. coop_state: coop_state || "",
  648. source: source || "",
  649. type: type || "",
  650. category: category || "",
  651. delivery_way: delivery_way || "",
  652. supplier_type: supplier_type || "",
  653. level: level || "",
  654. pay_type: pay_type || "",
  655. supplier_img: supplier_img || "",
  656. prove_img: prove_img ? (prove_img || "").split(",") : [],
  657. contactor: contactor || "",
  658. mobile: mobile || "",
  659. telephone: telephone || "",
  660. position: position || "",
  661. registercode: registercode || "",
  662. name: name || "",
  663. nature: nature || "",
  664. addr: addr || "",
  665. legaler: legaler || "",
  666. registertime: registertime || "",
  667. scope: scope || "",
  668. personid: personid ? [personid] : [],
  669. };
  670. },
  671. closeImg(index) {
  672. this.ruleForm.prove_img.splice(index, 1);
  673. this.$refs.ruleForm.validateField("prove_img");
  674. },
  675. async submitForm() {
  676. await this.$refs.ruleForm.validate(async (valid) => {
  677. if (valid) {
  678. this.loading = true;
  679. let model = JSON.parse(JSON.stringify(this.ruleForm));
  680. model.prove_img = model.prove_img.toString();
  681. model.personid = model.personid.toString();
  682. let res = {};
  683. if (this.id === "add") {
  684. delete model["id"];
  685. res = await asyncRequest.add(model);
  686. } else {
  687. res = await asyncRequest.update(model);
  688. }
  689. this.loading = false;
  690. if (res && res.code === 0) {
  691. const title = this.id === "add" ? "添加成功!" : "修改成功!";
  692. this.$notify.success({
  693. title,
  694. message: "",
  695. });
  696. this.showModelThis = false;
  697. // 刷新
  698. this.$emit("refresh", res.data);
  699. } else if (res && res.code >= 100 && res.code <= 104) {
  700. await this.logout();
  701. } else {
  702. this.$message.warning(res.message);
  703. }
  704. } else {
  705. console.log("error submit!!");
  706. return false;
  707. }
  708. });
  709. },
  710. deleteimg() {
  711. this.ruleForm.supplier_img = "";
  712. this.$refs.ruleForm.validateField("supplier_img");
  713. },
  714. handleHandoverName(e) {
  715. if (e && e.id) {
  716. this.ruleForm.personid = [e.id];
  717. } else {
  718. this.ruleForm.personid = [];
  719. }
  720. this.$refs.ruleForm.validateField("personid");
  721. },
  722. type_search_change(e) {
  723. const { id, code, label } = e;
  724. if (id) {
  725. this.ruleForm.nature = id;
  726. } else {
  727. this.ruleForm.nature = "";
  728. }
  729. this.$refs.ruleForm.validateField("nature");
  730. },
  731. //图片上传成功
  732. async UploadSuccessEventsupplier_img(data) {
  733. await this.UploadSuccessEvent(1, data);
  734. },
  735. // //图片上传成功
  736. // async UploadSuccessEventgood_img(data) {
  737. // await this.UploadSuccessEvent(2, data);
  738. // },
  739. //图片上传成功
  740. async UploadSuccessEventgood_info_img(data) {
  741. await this.UploadSuccessEvent(3, data);
  742. },
  743. //图片上传成功
  744. async UploadSuccessEvent(type, data) {
  745. const { url } = data;
  746. if (url === "noToken") {
  747. await this.logout();
  748. } else {
  749. if (type === 1) {
  750. this.ruleForm.supplier_img = url;
  751. this.$refs.ruleForm.validateField("supplier_img");
  752. } else if (type === 2) {
  753. this.ruleForm.good_img = url;
  754. this.$refs.ruleForm.validateField("good_img");
  755. } else {
  756. this.ruleForm.prove_img.push(url);
  757. this.$refs.ruleForm.validateField("prove_img");
  758. }
  759. this.$message.success("图片上传成功!");
  760. }
  761. },
  762. //图片上传失败
  763. UploadErrorEventsupplier_img(res) {
  764. this.imgUploadError(1, res);
  765. },
  766. // //图片上传失败
  767. // UploadErrorEventgood_img(res) {
  768. // this.imgUploadError(2, res);
  769. // },
  770. //图片上传失败
  771. UploadErrorEventgood_info_img(res) {
  772. this.imgUploadError(3, res);
  773. },
  774. imgUploadError(type, res) {
  775. if (res !== "break") {
  776. this.$message.error("图片上传失败!");
  777. this.$refs.ruleForm.validateField(
  778. type === 1
  779. ? "supplier_img"
  780. : type === 2
  781. ? "good_img"
  782. : "good_info_img"
  783. );
  784. }
  785. },
  786. //判断图片规格
  787. beforeAvatarUpload(file) {
  788. let isJPG = false;
  789. if (
  790. file.type === "image/jpg" ||
  791. file.type === "image/png" ||
  792. file.type === "image/jpeg"
  793. ) {
  794. isJPG = true;
  795. }
  796. const isLt2M = file.size / 1024 / 1024 < 1;
  797. if (!isJPG) {
  798. this.$message.error("图片格式不正确!");
  799. }
  800. if (!isLt2M) {
  801. this.$message.error("图片大小不能超过 1MB!");
  802. }
  803. return isJPG && isLt2M;
  804. },
  805. },
  806. };
  807. </script>
  808. <style lang="scss" scoped>
  809. .supplierAdd {
  810. .good_info_img_div {
  811. ul {
  812. width: 100%;
  813. li {
  814. float: left;
  815. width: 89px;
  816. height: 89px;
  817. padding: 0 5px 0 0;
  818. .img-show-li-div {
  819. width: 84px;
  820. height: 84px;
  821. border: 1px solid #dfe4ed;
  822. background: #dfe4ed;
  823. position: relative;
  824. img.img-show {
  825. width: 100%;
  826. height: 100%;
  827. position: relative;
  828. display: inline-block;
  829. }
  830. i.el-icon-close {
  831. position: absolute;
  832. z-index: 2;
  833. top: 0;
  834. right: 0;
  835. color: #dfe4ed;
  836. }
  837. &:hover {
  838. i.el-icon-close {
  839. cursor: pointer;
  840. color: #63cbe7;
  841. }
  842. }
  843. }
  844. }
  845. }
  846. }
  847. .supplierAdd-title {
  848. border-left: 5px solid #006eff;
  849. margin: 6px 0 25px 10px;
  850. width: 100%;
  851. box-sizing: border-box;
  852. padding: 0 0 0 10px;
  853. }
  854. }
  855. </style>