addEditForm.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. <template>
  2. <el-form
  3. ref="ruleForm"
  4. :loading="loading"
  5. :model="ruleForm"
  6. status-icon
  7. :size="'mini'"
  8. :rules="rulesThis"
  9. label-width="110px"
  10. style="width: 100%"
  11. >
  12. <el-row>
  13. <el-col :span="12">
  14. <el-form-item label="销售方" prop="companyNo" class="clear">
  15. <search-work-company
  16. :value="ruleForm.companyNo"
  17. :placeholder="'销售方公司'"
  18. :disabled="type === 'view'"
  19. :size="'mini'"
  20. :isDetail="type === 'view'"
  21. @searchChange="company_idsearchChange"
  22. />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="12">
  26. <el-form-item label="购买方公司" prop="khNo" class="clear">
  27. <search-customer
  28. :value="ruleForm.khNo"
  29. :names="ruleForm.customer_name"
  30. :placeholder="'购买方公司'"
  31. :size="'mini'"
  32. @searchChange="customerChange"
  33. :disabled="type === 'view'"
  34. :is-detail="type === 'view'"
  35. />
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item label="所属平台" prop="platform_code" class="clear">
  40. <search-terrace
  41. :value="ruleForm.platform_code"
  42. :disabled="type === 'view'"
  43. :size="'mini'"
  44. :isDetail="type === 'view'"
  45. :names="platform_code_name"
  46. :placeholder="'所属平台'"
  47. @searchChange="platform_code_codesearchChange"
  48. />
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="8">
  52. <el-form-item label="咨询截止时间" prop="endtime" class="clear">
  53. <el-date-picker
  54. v-model="ruleForm.endtime"
  55. type="datetime"
  56. value-format="yyyy-MM-dd hh:mm:ss"
  57. style="width: 100%"
  58. :picker-options="pickerOptions"
  59. placeholder="咨询截止时间"
  60. >
  61. </el-date-picker>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="8">
  65. <el-form-item label="咨询类型" prop="is_project" class="clear">
  66. <el-select
  67. v-model="ruleForm.is_project"
  68. style="width: 100%"
  69. placeholder="咨询类型"
  70. @change="is_project_change"
  71. >
  72. <el-option
  73. v-for="item in options"
  74. :key="item.value"
  75. :label="item.label"
  76. :value="item.value"
  77. >
  78. </el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8" v-if="ruleForm.is_project === '1'">
  83. <el-form-item label="项目名称" prop="projectNo" class="clear">
  84. <el-select
  85. v-model="ruleForm.projectNo"
  86. multiple
  87. filterable
  88. remote
  89. clearable
  90. :multiple-limit="1"
  91. reserve-keyword
  92. style="width: 100%"
  93. :placeholder="'项目名称'"
  94. :remote-method="remoteMethod"
  95. :loading="selectLoading"
  96. @change="selectChange"
  97. >
  98. <el-option
  99. v-for="(item, index) in poptions"
  100. :key="item.projectNo + index"
  101. :label="item.project_name"
  102. :value="item.projectNo + ''"
  103. :disabled="item.status !== '1'"
  104. >
  105. </el-option>
  106. </el-select>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="8" v-if="ruleForm.is_project === '1'">
  110. <el-form-item
  111. label="项目咨询截止时间"
  112. class="clear"
  113. required
  114. label-width="140px"
  115. >
  116. <el-input
  117. placeholder="项目咨询截止时间"
  118. v-model="ruleForm.pendtime"
  119. disabled
  120. maxlength="500"
  121. />
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="8" v-if="ruleForm.is_project === '1'">
  125. <el-form-item label="要求到货时间" class="clear" required>
  126. <el-input
  127. placeholder="要求到货时间"
  128. v-model="ruleForm.arrtime"
  129. disabled
  130. />
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="16" v-if="ruleForm.is_project === '1'">
  134. <el-form-item label="项目用途" class="clear" required>
  135. <el-input
  136. placeholder="项目用途"
  137. v-model="ruleForm.use_desc"
  138. disabled
  139. maxlength="500"
  140. />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="8" v-if="ruleForm.is_project === '1'">
  144. <el-form-item label="项目总预算" class="clear" required>
  145. <el-input
  146. placeholder="项目总预算"
  147. v-model="ruleForm.budget_total"
  148. disabled
  149. >
  150. <template slot="append">元</template></el-input
  151. >
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="24" v-if="ruleForm.is_project === '1'">
  155. <el-form-item label="项目商品要求" class="clear" required>
  156. <el-table
  157. ref="multipleTable"
  158. :data="ptableData"
  159. :size="'mini'"
  160. border
  161. stripe
  162. tooltip-effect="dark"
  163. style="width: 100%"
  164. @selection-change="handleSelectionChange"
  165. >
  166. <el-table-column type="selection" width="40"> </el-table-column>
  167. <el-table-column label="商品阶梯" width="70px">
  168. <template slot-scope="scope"> {{ scope.$index + 1 }}</template>
  169. </el-table-column>
  170. <el-table-column prop="good_type" label="商品类型" width="80px">
  171. <template slot-scope="scope">
  172. <el-tag
  173. :size="'mini'"
  174. v-text="
  175. (
  176. statusOptions.find(
  177. (item) => item.value == scope.row.good_type
  178. ) || {}
  179. ).label || '--'
  180. "
  181. ></el-tag
  182. ></template>
  183. </el-table-column>
  184. <el-table-column prop="good_name" label="商品名称" />
  185. <el-table-column prop="good_img" label="商品图片" width="70">
  186. <template slot-scope="scope">
  187. <div
  188. v-if="scope.row.good_img"
  189. style="width: 20px; height: 20px"
  190. class="hover"
  191. v-viewer
  192. >
  193. <img
  194. :src="scope.row.good_img"
  195. style="display: inline-block; width: 100%; height: 100%"
  196. alt=""
  197. />
  198. </div>
  199. </template>
  200. </el-table-column>
  201. <el-table-column prop="cat_name" label="商品分类" />
  202. <el-table-column prop="budget_price" label="预算单价" width="110" />
  203. <el-table-column prop="num" label="购买数量" width="110" />
  204. </el-table>
  205. </el-form-item>
  206. </el-col>
  207. <el-co :span="24">
  208. <el-form-item label="咨询商品要求" class="clear" required>
  209. <el-table
  210. :data="tableData"
  211. stripe
  212. border
  213. :size="'mini'"
  214. style="width: 100%"
  215. >
  216. <el-table-column type="expand">
  217. <template slot-scope="props">
  218. <show-data-table
  219. :sitem="props.row"
  220. :columns="addColumns"
  221. >
  222. <template slot="noble_type">
  223. <div>
  224. <span>贵金属克重:{{ props.row.specs_weight }}g</span>
  225. <span>--</span>
  226. <span>{{
  227. props.row.is_gold_price === "1"
  228. ? "启用实时金价"
  229. : "不启用实时金价"
  230. }}</span>
  231. <span>--</span>
  232. <span>当前金价:{{ props.row.gold_price }}元/g</span>
  233. <span>--</span>
  234. <span
  235. >配置要求:<span
  236. v-for="ii in props.row.config"
  237. :key="ii"
  238. >{{ ii }},</span
  239. ></span
  240. >
  241. <span>--</span>
  242. <span>其他配置要求:{{ props.row.other_config }}</span>
  243. </div>
  244. </template>
  245. </show-data-table>
  246. </template>
  247. </el-table-column>
  248. <el-table-column
  249. prop="arrival_time"
  250. label="到货时间"
  251. width="100"
  252. show-overflow-tooltip
  253. />
  254. <el-table-column
  255. prop="budget_price"
  256. label="预算单价"
  257. show-overflow-tooltip
  258. width="110"
  259. />
  260. <el-table-column
  261. prop="num"
  262. label="购买数量"
  263. show-overflow-tooltip
  264. width="80"
  265. />
  266. <el-table-column
  267. prop="cat_id_name"
  268. label="商品分类"
  269. show-overflow-tooltip
  270. min-width="170"
  271. />
  272. <el-table-column
  273. prop="good_img"
  274. label="图片"
  275. width="50"
  276. show-overflow-tooltip
  277. >
  278. <template slot-scope="scope">
  279. <img
  280. v-viewer
  281. style="width: 26px; height: 26px; margin: 5px 5px 0 0"
  282. class="fl"
  283. v-if="scope.row.good_img"
  284. :src="scope.row.good_img"
  285. alt=""
  286. />
  287. </template>
  288. </el-table-column>
  289. <el-table-column
  290. prop="good_name"
  291. label="商品名称"
  292. show-overflow-tooltip
  293. min-width="170"
  294. />
  295. <el-table-column
  296. prop="specinfo"
  297. label="商品规格"
  298. show-overflow-tooltip
  299. width="170"
  300. >
  301. <template slot-scope="scope">
  302. <span
  303. v-for="(si, sii) in scope.row.specinfo"
  304. :key="si.spec_name + sii"
  305. ><span v-if="sii !== 0">-</span>{{ si.spec_name }}:[{{
  306. si.spec_value_name
  307. }}]</span
  308. >
  309. </template>
  310. </el-table-column>
  311. <el-table-column
  312. prop="is_addrs"
  313. label="是否多地"
  314. width="70"
  315. show-overflow-tooltip
  316. >
  317. <template slot-scope="scope">
  318. {{ scope.row.is_addrs === "1" ? "多地" : "一地" }}
  319. </template>
  320. </el-table-column>
  321. <el-table-column
  322. prop="is_custom"
  323. label="是否定制"
  324. width="70"
  325. show-overflow-tooltip
  326. >
  327. <template slot-scope="scope">
  328. {{ scope.row.is_custom === "1" ? "定制" : "非定制" }}
  329. </template>
  330. </el-table-column>
  331. <el-table-column fixed="right" width="80">
  332. <template slot="header" slot-scope="scope">
  333. <span>操作</span>
  334. <el-tooltip
  335. class="item"
  336. effect="dark"
  337. v-if="status === ''"
  338. content="添加活动商品"
  339. placement="top"
  340. >
  341. <i
  342. class="el-icon-circle-plus-outline fr"
  343. style="font-size: 18px; margin-top: 2px"
  344. @click="openEdit(-1, {})"
  345. />
  346. </el-tooltip>
  347. </template>
  348. <template slot-scope="scope">
  349. <el-tooltip effect="dark" content="修改" placement="top">
  350. <i
  351. class="el-icon-edit tb-icon"
  352. @click="openEdit(scope.$index, scope.row)"
  353. ></i>
  354. </el-tooltip>
  355. <el-tooltip
  356. v-if="status === ''"
  357. effect="dark"
  358. content="删除"
  359. placement="top"
  360. >
  361. <i
  362. class="el-icon-delete tb-icon"
  363. @click="openCostEditDelete(scope.$index)"
  364. ></i>
  365. </el-tooltip>
  366. </template>
  367. </el-table-column>
  368. </el-table>
  369. </el-form-item>
  370. <add-edit-good-modal
  371. :showModel="showModel"
  372. :sitem="editItem"
  373. @cancel="showModel = false"
  374. @refresh="editGoodRefresh"
  375. />
  376. </el-co>
  377. <el-col :span="24" style="text-align: right" v-if="id === 'add'">
  378. <el-button type="primary" @click="submitForm" :size="'mini'"
  379. >保 存</el-button
  380. >
  381. </el-col>
  382. </el-row>
  383. </el-form>
  384. </template>
  385. <script>
  386. import asyncRequest from "@/apis/service/sellOut/bargainList";
  387. import resToken from "@/mixins/resToken";
  388. import {addColumns} from "./ShowDataTableColumns";
  389. import addEditGoodModal from "./addEditGoodModal";
  390. export default {
  391. name: "handover",
  392. props: ["id", "sitem", "newTime"],
  393. mixins: [resToken],
  394. components: {
  395. addEditGoodModal,
  396. },
  397. data() {
  398. return {
  399. multipleSelection: [],
  400. // 表格 - 数据
  401. tableData: [],
  402. ptableData: [],
  403. showModel: false,
  404. editItem: {},
  405. options: [
  406. { value: "0", label: "非项目" },
  407. { value: "1", label: "项目" },
  408. ],
  409. statusOptions: [
  410. { value: "1", label: "竞品" },
  411. { value: "2", label: "竞聘" },
  412. ],
  413. addColumns: addColumns,
  414. configOptions: ["证书", "包装盒", "绒布袋", "标签", "其他"],
  415. poptions: [],
  416. loading: false,
  417. selectLoading: false,
  418. pickerOptions: {
  419. disabledDate(time) {
  420. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  421. },
  422. },
  423. status: "", //存储详情接口返的状态
  424. ruleForm: {
  425. is_project: "0", //咨询类型 1非项目2项目,
  426. projectNo: [], //项目编号
  427. khNo: [], //客户编号
  428. customer_name: "", //客户名称
  429. companyNo: "",
  430. endtime: "", //咨询截止时间
  431. pendtime: "", //项目咨询截止时间
  432. platform_code: [], //平台id
  433. use_desc: "",
  434. budget_total: "",
  435. arrtime: "",
  436. },
  437. rulesThis: this.rules,
  438. // 验证规则
  439. rules: {
  440. companyNo: [
  441. {
  442. required: true,
  443. message: "请选择销售方公司",
  444. trigger: "change",
  445. },
  446. ],
  447. khNo: [
  448. {
  449. type: "array",
  450. required: true,
  451. message: "请选择购买方公司",
  452. trigger: "change",
  453. },
  454. ],
  455. platform_code: [
  456. {
  457. type: "array",
  458. required: true,
  459. message: "请选择所属平台",
  460. trigger: "change",
  461. },
  462. ],
  463. endtime: [
  464. {
  465. required: true,
  466. message: "咨询截止时间不能为空",
  467. trigger: "change",
  468. },
  469. ],
  470. is_project: [
  471. {
  472. required: true,
  473. message: "请选择咨询类型!",
  474. trigger: "change",
  475. },
  476. ],
  477. projectNo: [
  478. {
  479. type: "array",
  480. required: true,
  481. message: "请选择项目",
  482. trigger: "change",
  483. },
  484. ],
  485. },
  486. };
  487. },
  488. computed: {
  489. powers() {
  490. let tran =
  491. this.$store.getters.btnList.find(
  492. (item) => item.menu_route == "bargainListDetail"
  493. ) || {};
  494. if (tran && tran.action && tran.action.length > 0) {
  495. return tran.action;
  496. } else {
  497. return [];
  498. }
  499. },
  500. },
  501. mounted() {
  502. this.initForm();
  503. },
  504. watch: {
  505. id: function (val) {
  506. if (val) {
  507. this.initForm();
  508. }
  509. },
  510. newTime: function (val) {
  511. if (val) {
  512. this.initForm();
  513. }
  514. },
  515. },
  516. methods: {
  517. async initForm() {
  518. this.loading = true;
  519. this.status = "";
  520. this.rulesThis = this.rules;
  521. this.disabled = false;
  522. await this.resetForm();
  523. this.loading = false;
  524. },
  525. openEdit(index, editItem) {
  526. const { is_project } = this.ruleForm;
  527. if (index + "" == "-1" && is_project === "1") {
  528. if (this.multipleSelection.length === 0) {
  529. this.$message.warning("请选择一个项目商品要求!");
  530. return;
  531. }
  532. if (this.multipleSelection.length > 1) {
  533. this.$message.warning("每次创建只能选择一个项目商品要求!");
  534. return;
  535. }
  536. const {
  537. cat_info,
  538. budget_price,
  539. pgNo,
  540. num,
  541. good_type,
  542. good_name,
  543. good_img,
  544. } = this.multipleSelection[0];
  545. let cat_id = [];
  546. if (cat_info && cat_info.length > 0) {
  547. cat_info.forEach((e) => {
  548. cat_id.push(e.id);
  549. });
  550. }
  551. console.log(this.multipleSelection[0]);
  552. this.editItem = {
  553. p_cat_info: cat_info,
  554. p_cat_id: cat_id,
  555. p_budget_price: budget_price,
  556. p_pgNo: pgNo,
  557. p_num: num,
  558. p_good_type: good_type,
  559. p_good_name: good_name,
  560. p_good_img: good_img,
  561. p_arrtime: this.ruleForm.arrtime,
  562. };
  563. this.editItem.index = index;
  564. this.showModel = true;
  565. } else {
  566. this.editItem = editItem;
  567. this.editItem.index = index;
  568. this.showModel = true;
  569. }
  570. },
  571. handleSelectionChange(val) {
  572. this.multipleSelection = val;
  573. },
  574. editGoodRefresh(e) {
  575. console.log(e);
  576. const { index } = e;
  577. if (index + "" === "-1") {
  578. this.tableData.push(JSON.parse(JSON.stringify(e)));
  579. } else {
  580. const fsindex = parseInt(index + "");
  581. this.tableData[fsindex] = JSON.parse(JSON.stringify(e));
  582. this.$set(this.tableData, fsindex, this.tableData[fsindex]);
  583. }
  584. this.showModel = false;
  585. },
  586. //咨询类型选择
  587. is_project_change() {
  588. const { is_project } = this.ruleForm;
  589. if (is_project === "0") {
  590. } else {
  591. this.ptableData = [];
  592. }
  593. },
  594. openCostEditDelete(index) {
  595. this.tableData.splice(index, 1);
  596. },
  597. async resetForm() {
  598. this.resign_name = "";
  599. this.hand_name = "";
  600. this.status = "";
  601. // 重置
  602. await this.$nextTick(async () => {
  603. if (this.$refs.ruleForm) {
  604. this.$refs.ruleForm.resetFields();
  605. this.$refs.ruleForm.clearValidate();
  606. let {
  607. is_project, //咨询类型 1销售2咨询,
  608. projectNo, //项目编号
  609. khNo, //客户编号
  610. customer_name, //客户名称
  611. companyNo,
  612. endtime, //咨询截止时间
  613. platform_code, //平台id
  614. ladder,
  615. } = this.sitem;
  616. this.ruleForm = {
  617. is_project: is_project || "0", //咨询类型 1项目 0 非项目
  618. projectNo: projectNo ? [projectNo] : [], //项目编号
  619. khNo: khNo ? [khNo] : [], //客户编号
  620. customer_name: customer_name || "", //客户名称
  621. companyNo: companyNo || "",
  622. endtime: endtime || "", //咨询截止时间
  623. platform_code: platform_code ? [platform_code] : [], //平台id
  624. use_desc: "",
  625. budget_total: "",
  626. arrtime: "",
  627. };
  628. this.tableData =
  629. ladder && ladder.length > 0
  630. ? JSON.parse(JSON.stringify(ladder))
  631. : [];
  632. if (this.ruleForm.projectNo && this.ruleForm.projectNo.length === 1) {
  633. await this.selectChange(this.ruleForm.projectNo);
  634. }
  635. }
  636. });
  637. },
  638. async submitForm() {
  639. console.log(this.ruleForm);
  640. await this.$refs.ruleForm.validate(async (valid) => {
  641. if (valid) {
  642. // this.loading = true;
  643. if (this.tableData.length === 0) {
  644. this.$message.warning("至少提供一条商品要求!");
  645. this.loading = false;
  646. return;
  647. }
  648. let model = JSON.parse(JSON.stringify(this.ruleForm));
  649. const { pendtime, is_project, endtime } = model;
  650. if (
  651. is_project === "1" &&
  652. new Date(endtime).getTime() > new Date(pendtime).getTime()
  653. ) {
  654. this.$message.warning("咨询截止时间不能晚于项目咨询截止时间!");
  655. this.loading = false;
  656. return;
  657. }
  658. model.khNo = model.khNo.toString();
  659. model.platform_code = model.platform_code.toString();
  660. model.projectNo = model.projectNo.toString();
  661. model.ladder = [];
  662. let list = JSON.parse(JSON.stringify(this.tableData));
  663. list.forEach((e) => {
  664. let im = {
  665. good_name: e.good_name,
  666. good_img: e.good_img,
  667. cat_id: e.cat_id[e.cat_id.length - 1],
  668. unit: e.unit.toString(),
  669. brand_id: e.brand_id.toString(),
  670. arrival_time: e.arrival_time,
  671. cost_desc: e.cost_desc,
  672. is_addrs: e.is_addrs,
  673. is_custom: e.is_custom,
  674. metal_id: e.metal_id,
  675. config: e.config.toString(),
  676. other_config: e.other_config,
  677. specs_weight: e.specs_weight,
  678. gold_price: e.gold_price,
  679. budget_price: e.budget_price,
  680. num: e.num,
  681. use_desc: e.use_desc,
  682. remark: e.remark,
  683. pgNo: e.pgNo,
  684. total_weight: e.total_weight,
  685. is_gold_price: e.is_gold_price,
  686. specinfo: [],
  687. };
  688. e.specinfo.forEach((a) => {
  689. let am = {
  690. specid: a.specid,
  691. spec_value_id: a.spec_value_id,
  692. };
  693. im.specinfo.push(am);
  694. });
  695. model.ladder.push(im);
  696. });
  697. console.log(model);
  698. const res = await asyncRequest.add(model);
  699. this.loading = false;
  700. if (res && res.code === 0) {
  701. this.$notify.success({
  702. title: "创建成功!",
  703. message: "",
  704. });
  705. this.$emit("refresh", true);
  706. } else if (res && res.code >= 100 && res.code <= 104) {
  707. await this.logout();
  708. } else {
  709. this.$message.warning(res.message);
  710. }
  711. } else {
  712. console.log("error submit!!");
  713. return false;
  714. }
  715. });
  716. },
  717. // //获取规格值
  718. // setResData() {
  719. // let list = JSON.parse(JSON.stringify(this.spec_tableData));
  720. // let oldlist = JSON.parse(JSON.stringify(this.old_spec_tableData));
  721. // let hasIDlist = [];
  722. // list.forEach((a) => {
  723. // if (a.id !== "") {
  724. // hasIDlist.push(a);
  725. // }
  726. // });
  727. // let newList = [];
  728. // let resList = [];
  729. // oldlist.forEach((a, ai) => {
  730. // let item = null;
  731. // let index = hasIDlist.findIndex((b) => a.id === b.id);
  732. // if (index === -1) {
  733. // item = JSON.parse(JSON.stringify(a));
  734. // item.is_del = "1";
  735. // } else {
  736. // item = JSON.parse(JSON.stringify(hasIDlist[index]));
  737. // }
  738. // newList.push(item);
  739. // });
  740. // list.forEach((b) => {
  741. // if (b.id === "") {
  742. // b.is_del = "0";
  743. // newList.push(b);
  744. // }
  745. // });
  746. // newList.forEach((a) => {
  747. // let m = {
  748. // id: a.id,
  749. // specid: a.specid,
  750. // spec_value_id: a.spec_value_id,
  751. // is_del: a.is_del || "0",
  752. // };
  753. // resList.push(m);
  754. // });
  755. // return resList;
  756. // },
  757. //项目选择
  758. async selectChange(e) {
  759. const key = e && e.length > 0 ? e[0] : "";
  760. if (key) {
  761. const { code, data, message } = await asyncRequest.pdetail({
  762. projectNo: key,
  763. });
  764. if (code === 0) {
  765. const { use_desc, budget_total, ladder, arrtime, endtime } = data;
  766. this.ruleForm.use_desc = use_desc || "";
  767. this.ruleForm.budget_total = budget_total || "";
  768. this.ruleForm.arrtime = arrtime || "";
  769. this.ruleForm.pendtime = endtime || "";
  770. this.ptableData = ladder;
  771. this.ptableData.forEach((e) => {
  772. e.cat_name = "";
  773. const { cat_info } = e;
  774. if (cat_info && cat_info.length > 0) {
  775. cat_info.forEach((b, bi) => {
  776. e.cat_name += bi !== 0 ? "/" + b.name : b.name;
  777. });
  778. }
  779. });
  780. this.tableData == [];
  781. } else if (code >= 100 && code <= 104) {
  782. await this.logout();
  783. } else {
  784. this.$message.warning(message);
  785. this.ptableData = [];
  786. this.ruleForm.use_desc = "";
  787. this.ruleForm.budget_total = "";
  788. this.ruleForm.arrtime = "";
  789. this.tableData == [];
  790. }
  791. } else {
  792. this.ptableData = [];
  793. this.ruleForm.use_desc = "";
  794. this.ruleForm.budget_total = "";
  795. this.ruleForm.arrtime = "";
  796. this.tableData = [];
  797. }
  798. },
  799. async remoteMethod(query) {
  800. this.selectLoading = true;
  801. this.poptions = [];
  802. const { platform_code, companyNo, khNo } = JSON.parse(
  803. JSON.stringify(this.ruleForm)
  804. );
  805. if (!companyNo) {
  806. this.$message.warning("请选择销售方公司!");
  807. this.selectLoading = false;
  808. return;
  809. }
  810. if (khNo.length === 0) {
  811. this.$message.warning("请选择购买方公司!");
  812. this.selectLoading = false;
  813. return;
  814. }
  815. if (platform_code.length === 0) {
  816. this.$message.warning("请选择所属平台!");
  817. this.selectLoading = false;
  818. return;
  819. }
  820. if (!query) {
  821. this.selectLoading = false;
  822. return;
  823. }
  824. let formValue = {
  825. page: 1,
  826. size: 100,
  827. khNo: khNo.toString(),
  828. companyNo: companyNo,
  829. platform_code: platform_code.toString(),
  830. status: "1",
  831. project_name: query,
  832. };
  833. const { code, data, message } = await asyncRequest.plist(formValue);
  834. if (code === 0) {
  835. const { list } = data;
  836. this.poptions = list;
  837. } else if (code >= 100 && code <= 104) {
  838. await this.logout();
  839. } else {
  840. this.$message.warning(message);
  841. this.poptions = [];
  842. }
  843. this.selectLoading = false;
  844. },
  845. //平台选择
  846. platform_code_codesearchChange(e) {
  847. const { id, code, label } = e;
  848. this.ruleForm.platform_code = id ? [id] : [];
  849. this.$refs.ruleForm.validateField("platform_code");
  850. this.ruleForm.projectNo = [];
  851. this.ruleForm.budget_total = "0";
  852. this.ruleForm.use_desc = "";
  853. this.ruleForm.pendtime = "";
  854. this.ruleForm.arrtime = "";
  855. this.ptableData = [];
  856. this.tableData = [];
  857. },
  858. //销售方公司选择
  859. company_idsearchChange(e) {
  860. if (e) {
  861. const { id, code, label } = e;
  862. this.ruleForm.companyNo = code || "";
  863. }
  864. this.$refs.ruleForm.validateField("companyNo");
  865. },
  866. //购买方公司选择
  867. customerChange(e) {
  868. if (e && e.id) {
  869. this.ruleForm.khNo = [e.code];
  870. this.ruleForm.customer_name = e.label;
  871. } else {
  872. this.ruleForm.khNo = [];
  873. this.ruleForm.customer_name = "";
  874. }
  875. this.$refs.ruleForm.validateField("khNo");
  876. this.ruleForm.projectNo = [];
  877. this.ruleForm.budget_total = "0";
  878. this.ruleForm.use_desc = "";
  879. this.ruleForm.pendtime = "";
  880. this.ruleForm.arrtime = "";
  881. this.ptableData = [];
  882. this.tableData = [];
  883. },
  884. },
  885. };
  886. </script>
  887. <style lang="scss" scoped>
  888. .el-form-item-error-img {
  889. width: 100%;
  890. ul {
  891. width: 100%;
  892. li {
  893. float: left;
  894. border: 1px solid rgb(220, 223, 230);
  895. // border-left: 0;
  896. box-sizing: border-box;
  897. width: 254px;
  898. height: 164px;
  899. line-height: 164px;
  900. position: relative;
  901. img {
  902. display: inline-block;
  903. width: 100%;
  904. height: 100%;
  905. }
  906. .el-icon-close {
  907. position: absolute;
  908. top: 0;
  909. right: 0;
  910. z-index: 2;
  911. width: 25px;
  912. height: 25px;
  913. text-align: center;
  914. line-height: 25px;
  915. font-size: 19px;
  916. &:hover {
  917. color: #63cbe7;
  918. }
  919. }
  920. }
  921. }
  922. }
  923. .images_li {
  924. // width: 254px;
  925. // height: 164px;
  926. float: left;
  927. }
  928. .btnupload {
  929. float: left;
  930. border: 1px solid rgb(220, 223, 230);
  931. // border-left: 0;
  932. box-sizing: border-box;
  933. width: 254px;
  934. height: 164px;
  935. line-height: 164px;
  936. text-align: center;
  937. }
  938. .Upload {
  939. width: 254px;
  940. height: 164px;
  941. line-height: 164px;
  942. text-align: center;
  943. position: absolute;
  944. line-height: 0px;
  945. top: 0;
  946. left: 0;
  947. z-index: 2;
  948. line-height: 164px;
  949. }
  950. .avatar-uploader-icon {
  951. font-size: 33px;
  952. color: #8c939d;
  953. width: 50px;
  954. height: 50px;
  955. line-height: 50px;
  956. text-align: center;
  957. }
  958. </style>