index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  5. :statConfig="statConfig" :onMoreSearch="false" @moreSearch="clickMoreSearch" highlight-current-row :action-list="[
  6. {
  7. text: '新建销售合同',
  8. action: () => newContract(),
  9. },
  10. ]" @get-list="getList">
  11. <template #code="{ item }">
  12. <div style="width: 100%">
  13. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="openDetails(item)">{{ item.code }}</a>
  14. </div>
  15. </template>
  16. <template #isSettled="{ item }">
  17. <div>
  18. <span style="padding: 4px" :class="[item.isSettled == 1 ? 'active' : '']">
  19. {{
  20. proxy.dictValueLabel(item.isSettled, isSettled)
  21. }}</span>
  22. </div>
  23. </template>
  24. <template #amount="{ item }">
  25. <div>
  26. <span style="padding-right: 4px">{{ item.currency }}</span>
  27. <span>{{ moneyFormat(item.amount, 2) }}</span>
  28. </div>
  29. </template>
  30. <template #buyCorporationName="{ item }">
  31. <div style="width: 100%">
  32. <a style="color: #409eff; cursor: pointer" @click="clickCorporationName(item)">{{ item.buyCorporationName }}</a>
  33. </div>
  34. </template>
  35. <template #tags="{ item }">
  36. <div style="width: 100%">
  37. <el-tag style="margin-right: 8px" type="success" v-for="(tag, index) in item.tags" closable :key="index" @close="tagClose(tag, item)">
  38. {{ dictValueLabel(tag, customerTag) }}
  39. </el-tag>
  40. <template v-if="item.tags.length !== customerTag.length">
  41. <el-select v-if="item.addTagShow" v-model="addTag" style="width: 100%" @change="
  42. (val) => {
  43. return changeTag(val, item);
  44. }
  45. ">
  46. <el-option v-for="tag in customerTag" :key="tag.value" :label="tag.label" :value="tag.value"
  47. :disabled="judgeTagSelect(item.tags, tag.value)" />
  48. </el-select>
  49. <el-tag style="cursor: pointer" type="success" @click="showSelect(item)" v-else>
  50. +
  51. </el-tag>
  52. </template>
  53. </div>
  54. </template>
  55. <template #advanceRatio="{ item }">
  56. <div>
  57. <span>{{ moneyFormat(item.advanceRatio, 2) }}%</span>
  58. </div>
  59. </template>
  60. <template #scale="{ item }">
  61. <div>
  62. {{ computeScale(item) }}
  63. </div>
  64. </template>
  65. </byTable>
  66. </div>
  67. <el-dialog title="打印" v-if="openPrint" v-model="openPrint" width="920">
  68. <!-- <ContractPDFOne :rowData="rowData"></ContractPDFOne> -->
  69. <ContractPDFOneNew :rowData="rowData" ref="PdfDom"></ContractPDFOneNew>
  70. <template #footer>
  71. <el-button @click="openPrint = false" size="default">取消</el-button>
  72. <el-button type="primary" v-print="printObj" size="default">打印</el-button>
  73. <el-button type="primary" @click="clickDownload()" size="default">下载PDF</el-button>
  74. <el-button type="primary" @click="exportExcel()" size="default">导出Excel</el-button>
  75. </template>
  76. </el-dialog>
  77. <el-dialog title="交接单" v-if="openHandoverSlip" v-model="openHandoverSlip" width="600">
  78. <byForm :formConfig="formConfig" :formOption="formOption" v-model="handoverSlipForm">
  79. <template #file>
  80. <div style="width: 100%">
  81. <el-upload v-model:fileList="handoverSlipForm.fileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com" :data="uploadData"
  82. multiple :before-upload="uploadFile" :on-success="handleSuccess" :on-preview="onPreviewFile">
  83. <el-button type="primary" plain>选择</el-button>
  84. </el-upload>
  85. </div>
  86. </template>
  87. <template #indication>
  88. <div style="width: 100%">
  89. <el-upload v-model:fileList="handoverSlipForm.packageFileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  90. :data="indicationUploadData" multiple :before-upload="indicationUploadFile" :on-success="handleSuccess"
  91. :on-preview="onPreviewFile">
  92. <el-button type="primary" plain>选择</el-button>
  93. </el-upload>
  94. </div>
  95. </template>
  96. </byForm>
  97. <template #footer>
  98. <el-button @click="openHandoverSlip = false" size="default">关 闭</el-button>
  99. <el-button type="primary" @click="submitHandoverSlip()" size="default">确 定</el-button>
  100. </template>
  101. </el-dialog>
  102. <el-dialog title="合同详情" v-if="openDetailsDialog" v-model="openDetailsDialog" width="1100">
  103. <ContractDetails :contractId="currentContractId"></ContractDetails>
  104. </el-dialog>
  105. <el-dialog :title="`售后记录`" v-if="openRecords" v-model="openRecords" width="600">
  106. <div style="padding-left: 50px; margin-bottom: 20px">
  107. <el-button type="primary" plain @click="handleClickAddRecord()">添加记录</el-button>
  108. </div>
  109. <el-timeline>
  110. <el-timeline-item v-for="(activity, index) in recordsData" :key="index">
  111. <div style="
  112. width: 100%;
  113. display: flex;
  114. justify-content: space-between;
  115. color: #bfb9b9;
  116. ">
  117. <div>售后时间:{{ activity.documentaryTime }}</div>
  118. <div>{{ activity.userName }}</div>
  119. </div>
  120. <div style="width: 100%; margin-top: 8px">
  121. 售后记录:{{ activity.documentaryRemark }}
  122. </div>
  123. <div style="width: 100%; margin-top: 8px" v-if="activity.fileList && activity.fileList.length > 0">
  124. <div v-for="(item, index) in activity.fileList" :key="index">
  125. <div style="cursor: pointer; color: #409eff" @click="openFile(item)">
  126. {{ item.fileName }}
  127. </div>
  128. </div>
  129. </div>
  130. </el-timeline-item>
  131. </el-timeline>
  132. <template #footer>
  133. <el-button @click="openRecords = false" size="default">关 闭</el-button>
  134. </template>
  135. </el-dialog>
  136. <el-dialog :title="`添加售后记录`" v-if="openAddRecords" v-model="openAddRecords" width="600">
  137. <byForm :formConfig="recordsFormConfig" :formOption="formOption" v-model="formData.recordsFormData" :rules="recordsRules" ref="recordsForm"
  138. v-loading="formLoading">
  139. <template #file>
  140. <div style="width: 100%">
  141. <el-upload v-model:fileList="formData.recordsFormData.fileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  142. :data="uploadData" multiple :before-upload="uploadFile" :on-success="handleSuccess" :on-preview="onPreviewFile">
  143. <el-button type="primary" plain>选择</el-button>
  144. </el-upload>
  145. </div>
  146. </template>
  147. </byForm>
  148. <template #footer>
  149. <el-button @click="openAddRecords = false" size="default">关 闭</el-button>
  150. <el-button type="primary" @click="submitRecords()" size="default">确 定</el-button>
  151. </template>
  152. </el-dialog>
  153. <el-dialog :title="'高级检索'" v-model="moreSearchDialog" width="500px" destroy-on-close>
  154. <byForm :formConfig="formSearchConfig" :formOption="formOption" v-model="sourceList.pagination">
  155. </byForm>
  156. <template #footer>
  157. <el-button @click="moreSearchReset" size="default">重置</el-button>
  158. <el-button @click="moreSearchQuery" type="primary" size="default" v-debounce>搜索</el-button>
  159. </template>
  160. </el-dialog>
  161. <el-dialog :title="'下发生产'" v-model="productionDialog" width="500px" destroy-on-close>
  162. <byForm :formConfig="productionFormConfig" :formOption="formOption" v-model="formData.data" :rules="productionRules" ref="productionFormDom"
  163. v-loading="formLoading">
  164. </byForm>
  165. <template #footer>
  166. <el-button @click="productionDialog =false" size="default">取 消</el-button>
  167. <el-button @click="submitProduction" type="primary" size="default" v-debounce>下 发</el-button>
  168. </template>
  169. </el-dialog>
  170. </div>
  171. </template>
  172. <script setup>
  173. import { computed, ref } from "vue";
  174. import byTable from "@/components/byTable/index";
  175. import byForm from "@/components/byForm/index";
  176. import useUserStore from "@/store/modules/user";
  177. import { ElMessage, ElMessageBox } from "element-plus";
  178. import ContractDetails from "@/components/contractCom/contractDetails.vue";
  179. import ContractPDFOne from "@/components/PDF/contractPDFOne.vue";
  180. import ContractPDFOneNew from "@/components/PDF/contractPDFOneNew.vue";
  181. const route = useRoute();
  182. const { proxy } = getCurrentInstance();
  183. const accountCurrency = ref([]);
  184. const tradeMethods = ref([]);
  185. const corporationList = ref([]);
  186. const customerList = ref([]);
  187. const userList = ref([]);
  188. const companyData = ref([]);
  189. const isSettled = ref([
  190. {
  191. label: "已结清",
  192. value: "1",
  193. },
  194. {
  195. label: "未结清",
  196. value: "0",
  197. },
  198. ]);
  199. const shippingMethod = ref([]);
  200. const customerTag = ref([]);
  201. const openDetailsDialog = ref(false);
  202. const status = ref([
  203. {
  204. label: "草稿",
  205. value: 0,
  206. },
  207. {
  208. label: "审批中",
  209. value: 10,
  210. },
  211. {
  212. label: "驳回",
  213. value: 20,
  214. },
  215. {
  216. label: "审批通过",
  217. value: 30,
  218. },
  219. {
  220. label: "变更中",
  221. value: 60,
  222. },
  223. {
  224. label: "已变更",
  225. value: 70,
  226. },
  227. {
  228. label: "作废",
  229. value: 88,
  230. },
  231. {
  232. label: "终止",
  233. value: 99,
  234. },
  235. ]);
  236. const sourceList = ref({
  237. data: [],
  238. pagination: {
  239. total: 0,
  240. pageNum: 1,
  241. pageSize: 10,
  242. keyword: "",
  243. status: "",
  244. companyId: "",
  245. userId: "",
  246. isSettled: "",
  247. beginTime: "",
  248. endTime: "",
  249. },
  250. });
  251. const loading = ref(false);
  252. const selectConfig = computed(() => {
  253. return [
  254. {
  255. label: "审批状态",
  256. prop: "status",
  257. data: status.value,
  258. },
  259. {
  260. label: "归属公司",
  261. prop: "companyId",
  262. data: companyData.value,
  263. },
  264. {
  265. label: "业务员",
  266. prop: "userId",
  267. data: userList.value,
  268. },
  269. {
  270. label: "是否已结清",
  271. prop: "isSettled",
  272. data: isSettled.value,
  273. },
  274. {
  275. type: "time",
  276. label: "创建时间",
  277. placeholder: "开始日期",
  278. prop: "beginTime",
  279. placeholderOne: "结束日期",
  280. propOne: "endTime",
  281. },
  282. ];
  283. });
  284. const headerData = ref({});
  285. const statConfig = computed(() => [
  286. // {
  287. // label: "统计",
  288. // data: [
  289. // //一个卡牌多数据配置
  290. // {
  291. // label: "订单统计(CNY)",
  292. // type: 2,
  293. // data: [
  294. // {
  295. // label: "订单数",
  296. // num: headerData.value.count,
  297. // color: "#C280FF",
  298. // },
  299. // {
  300. // label: "客户数",
  301. // num: headerData.value.customerCount,
  302. // color: "#C280FF",
  303. // },
  304. // {
  305. // label: "订单金额",
  306. // num: proxy.moneyFormat(headerData.value.sumAmount, 2),
  307. // color: "#C280FF",
  308. // },
  309. // ],
  310. // },
  311. // {
  312. // label: "款项统计(CNY)",
  313. // type: 3,
  314. // data: [
  315. // {
  316. // label: "已收款",
  317. // num: proxy.moneyFormat(headerData.value.sumClaimMoney, 2),
  318. // color: "#FF9315",
  319. // },
  320. // {
  321. // label: "待收款",
  322. // num: proxy.moneyFormat(headerData.value.sumClaimMoneyOne, 2),
  323. // color: "#FF9315",
  324. // },
  325. // ],
  326. // },
  327. // ],
  328. // },
  329. ]);
  330. const config = computed(() => {
  331. return [
  332. {
  333. attrs: {
  334. label: "合同号",
  335. slot: "code",
  336. width: 140,
  337. },
  338. },
  339. {
  340. attrs: {
  341. label: "归属公司",
  342. prop: "companyName",
  343. "min-width": 150,
  344. },
  345. },
  346. {
  347. attrs: {
  348. label: "业务员",
  349. prop: "salesmanName",
  350. width: 100,
  351. },
  352. // render(type) {
  353. // return proxy.dictValueLabel(type, userList.value);
  354. // },
  355. },
  356. {
  357. attrs: {
  358. label: "下单时间",
  359. prop: "createTime",
  360. width: 160,
  361. },
  362. },
  363. {
  364. attrs: {
  365. label: "客户名称",
  366. slot: "buyCorporationName",
  367. "min-width": 140,
  368. },
  369. },
  370. // {
  371. // attrs: {
  372. // label: "客户标签",
  373. // slot: "tags",
  374. // width: 180,
  375. // },
  376. // },
  377. {
  378. attrs: {
  379. label: "是否已结清",
  380. slot: "isSettled",
  381. width: 100,
  382. },
  383. // render(type) {
  384. // return proxy.dictValueLabel(type, isSettled.value);
  385. // },
  386. },
  387. {
  388. attrs: {
  389. label: "预付比例",
  390. slot: "advanceRatio",
  391. width: 100,
  392. align: "right",
  393. },
  394. },
  395. {
  396. attrs: {
  397. label: "合同金额",
  398. slot: "amount",
  399. width: 140,
  400. align: "right",
  401. },
  402. },
  403. {
  404. attrs: {
  405. label: "汇率",
  406. prop: "rate",
  407. width: 80,
  408. align: "right",
  409. },
  410. render(rate) {
  411. return proxy.moneyFormat(rate, 4);
  412. },
  413. },
  414. // {
  415. // attrs: {
  416. // label: "合同金额(CNY)",
  417. // prop: "amountCNY",
  418. // width: 160,
  419. // align: "right",
  420. // },
  421. // render(amountCNY) {
  422. // return proxy.moneyFormat(amountCNY, 2);
  423. // },
  424. // },
  425. // {
  426. // attrs: {
  427. // label: "到账金额(CNY)",
  428. // prop: "sumClaimMoney",
  429. // width: 160,
  430. // align: "right",
  431. // },
  432. // render(sumClaimMoney) {
  433. // return proxy.moneyFormat(sumClaimMoney, 2);
  434. // },
  435. // },
  436. // {
  437. // attrs: {
  438. // label: "到账比例",
  439. // slot: "scale",
  440. // width: 100,
  441. // align: "right",
  442. // },
  443. // },
  444. {
  445. attrs: {
  446. label: "审批状态",
  447. prop: "status",
  448. width: 100,
  449. },
  450. render(type) {
  451. return proxy.dictValueLabel(type, status.value);
  452. },
  453. },
  454. {
  455. attrs: {
  456. label: "操作",
  457. width: 200,
  458. align: "center",
  459. fixed: "right",
  460. },
  461. renderHTML(row) {
  462. return [
  463. // {
  464. // attrs: {
  465. // label: "交接单",
  466. // type: "primary",
  467. // text: true,
  468. // },
  469. // el: "button",
  470. // click() {
  471. // clickHandoverSlip(row);
  472. // },
  473. // },
  474. row.status == 30
  475. ? {
  476. attrs: {
  477. label: "变更",
  478. type: "primary",
  479. text: true,
  480. },
  481. el: "button",
  482. click() {
  483. clickAlteration(row);
  484. },
  485. }
  486. : {},
  487. row.status == 30
  488. ? {
  489. attrs: {
  490. label: "下发生产",
  491. type: "primary",
  492. text: true,
  493. },
  494. el: "button",
  495. click() {
  496. clickDistributeProduction(row);
  497. },
  498. }
  499. : {},
  500. {
  501. attrs: {
  502. label: "打印",
  503. type: "primary",
  504. text: true,
  505. },
  506. el: "button",
  507. click() {
  508. clickPrint(row);
  509. },
  510. },
  511. {
  512. attrs: {
  513. label: "作废",
  514. type: "primary",
  515. text: true,
  516. },
  517. el: "button",
  518. click() {
  519. ElMessageBox.confirm(
  520. "此操作将永久删除该数据, 是否继续?",
  521. "提示",
  522. {
  523. confirmButtonText: "确定",
  524. cancelButtonText: "取消",
  525. type: "warning",
  526. }
  527. ).then(() => {
  528. proxy
  529. .post("/contract/edit", {
  530. id: row.id,
  531. status: 88,
  532. })
  533. .then(() => {
  534. ElMessage({
  535. message: "作废成功",
  536. type: "success",
  537. });
  538. getList();
  539. });
  540. });
  541. },
  542. },
  543. row.status == 30
  544. ? {
  545. attrs: {
  546. label: "结清",
  547. type: "primary",
  548. text: true,
  549. },
  550. el: "button",
  551. click() {
  552. ElMessageBox.confirm("是否确认结清?", "提示", {
  553. confirmButtonText: "确定",
  554. cancelButtonText: "取消",
  555. type: "warning",
  556. }).then(() => {
  557. proxy
  558. .post("/contract/settle", {
  559. id: row.id,
  560. })
  561. .then(() => {
  562. ElMessage({
  563. message: "操作成功",
  564. type: "success",
  565. });
  566. getList();
  567. });
  568. });
  569. },
  570. }
  571. : {},
  572. {
  573. attrs: {
  574. label: "售后",
  575. type: "primary",
  576. text: true,
  577. },
  578. el: "button",
  579. click() {
  580. openRecords.value = true;
  581. getRecordsData(row);
  582. },
  583. },
  584. ];
  585. },
  586. },
  587. ];
  588. });
  589. const getDict = () => {
  590. proxy
  591. .getDictOne([
  592. "customer_tag",
  593. "trade_mode",
  594. "account_currency",
  595. "shipping_method",
  596. ])
  597. .then((res) => {
  598. customerTag.value = res["customer_tag"].map((x) => ({
  599. label: x.dictValue,
  600. value: x.dictKey,
  601. }));
  602. tradeMethods.value = res["trade_mode"].map((x) => ({
  603. label: x.dictValue,
  604. value: x.dictKey,
  605. }));
  606. accountCurrency.value = res["account_currency"].map((x) => ({
  607. label: x.dictValue,
  608. value: x.dictKey,
  609. }));
  610. shippingMethod.value = res["shipping_method"].map((x) => ({
  611. label: x.dictValue,
  612. value: x.dictKey,
  613. }));
  614. });
  615. // proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  616. // corporationList.value = res.rows.map((item) => {
  617. // return {
  618. // ...item,
  619. // label: item.name,
  620. // value: item.id,
  621. // };
  622. // });
  623. // });
  624. proxy
  625. .get("/tenantDept/list", {
  626. pageNum: 1,
  627. pageSize: 9999,
  628. keyword: "",
  629. tenantId: proxy.useUserStore().user.tenantId,
  630. type: 0,
  631. })
  632. .then((res) => {
  633. companyData.value = res.data.map((x) => ({
  634. ...x,
  635. label: x.deptName,
  636. value: x.deptId,
  637. }));
  638. });
  639. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  640. customerList.value = res.rows.map((item) => {
  641. return {
  642. ...item,
  643. label: item.name,
  644. value: item.id,
  645. };
  646. });
  647. });
  648. proxy
  649. .get("/tenantUser/list", {
  650. pageNum: 1,
  651. pageSize: 10000,
  652. tenantId: useUserStore().user.tenantId,
  653. })
  654. .then((res) => {
  655. userList.value = res.rows.map((item) => {
  656. return {
  657. label: item.nickName,
  658. value: item.userId,
  659. };
  660. });
  661. });
  662. };
  663. const getList = async (req) => {
  664. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  665. loading.value = true;
  666. proxy.post("/contract/page", sourceList.value.pagination).then((res) => {
  667. res.rows.forEach((x) => {
  668. x.addTagShow = false;
  669. if (x.tag) {
  670. x.tags = x.tag.split(",");
  671. } else {
  672. x.tags = [];
  673. }
  674. });
  675. sourceList.value.data = res.rows;
  676. sourceList.value.pagination.total = res.total;
  677. setTimeout(() => {
  678. loading.value = false;
  679. }, 200);
  680. });
  681. proxy
  682. .post("/contract/getHeadStatistic", sourceList.value.pagination)
  683. .then((res) => {
  684. headerData.value = res;
  685. if (headerData.value) {
  686. headerData.value.sumClaimMoneyOne = parseFloat(
  687. Number(headerData.value.sumAmount) -
  688. Number(headerData.value.sumClaimMoney)
  689. ).toFixed(2);
  690. }
  691. });
  692. };
  693. getDict();
  694. if (route.query.code) {
  695. sourceList.value.pagination.keyword = route.query.code;
  696. }
  697. getList();
  698. const newContract = () => {
  699. proxy.$router.replace({
  700. path: "/platform_manage/process/processApproval",
  701. query: {
  702. flowKey: "contract_flow",
  703. flowName: "销售合同审批流程",
  704. random: proxy.random(),
  705. },
  706. });
  707. };
  708. const openPrint = ref(false);
  709. const rowData = ref({});
  710. const clickPrint = (row) => {
  711. rowData.value = {
  712. id: row.id,
  713. };
  714. openPrint.value = true;
  715. };
  716. const clickDownload = () => {
  717. proxy.getPdf("外销合同PDF文件");
  718. };
  719. const openHandoverSlip = ref(false);
  720. const handoverSlipForm = ref({
  721. id: "",
  722. code: "",
  723. buyCorporationName: "",
  724. fileList: [],
  725. packageFileList: [],
  726. });
  727. const formOption = reactive({
  728. inline: true,
  729. labelWidth: 100,
  730. itemWidth: 100,
  731. rules: [],
  732. });
  733. const formConfig = computed(() => {
  734. return [
  735. {
  736. type: "input",
  737. prop: "code",
  738. label: "合同编号",
  739. itemType: "text",
  740. disabled: true,
  741. },
  742. {
  743. type: "input",
  744. prop: "buyCorporationName",
  745. label: "客户名称",
  746. itemType: "text",
  747. disabled: true,
  748. },
  749. {
  750. type: "slot",
  751. slotName: "file",
  752. label: "交接单",
  753. },
  754. {
  755. type: "slot",
  756. slotName: "indication",
  757. label: "包装指示",
  758. },
  759. ];
  760. });
  761. const uploadData = ref({});
  762. const indicationUploadData = ref({});
  763. const clickHandoverSlip = (item) => {
  764. handoverSlipForm.value.id = item.id;
  765. handoverSlipForm.value.code = item.code;
  766. handoverSlipForm.value.buyCorporationName = item.buyCorporationName;
  767. if (item.fileInfoVos && item.fileInfoVos.length > 0) {
  768. handoverSlipForm.value.fileList = item.fileInfoVos.map((item) => {
  769. return {
  770. raw: item,
  771. name: item.fileName,
  772. url: item.fileUrl,
  773. };
  774. });
  775. } else {
  776. handoverSlipForm.value.fileList = [];
  777. }
  778. if (item.packageFileInfoVOList && item.packageFileInfoVOList.length > 0) {
  779. handoverSlipForm.value.packageFileList = item.packageFileInfoVOList.map(
  780. (item) => {
  781. return {
  782. raw: item,
  783. name: item.fileName,
  784. url: item.fileUrl,
  785. };
  786. }
  787. );
  788. } else {
  789. handoverSlipForm.value.packageFileList = [];
  790. }
  791. openHandoverSlip.value = true;
  792. };
  793. const uploadFile = async (file) => {
  794. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  795. uploadData.value = res.uploadBody;
  796. file.id = res.id;
  797. file.fileName = res.fileName;
  798. file.fileUrl = res.fileUrl;
  799. file.uploadState = true;
  800. return true;
  801. };
  802. const indicationUploadFile = async (file) => {
  803. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  804. indicationUploadData.value = res.uploadBody;
  805. file.id = res.id;
  806. file.fileName = res.fileName;
  807. file.fileUrl = res.fileUrl;
  808. file.uploadState = true;
  809. return true;
  810. };
  811. const handleSuccess = (any, UploadFile) => {
  812. UploadFile.raw.uploadState = false;
  813. };
  814. const onPreviewFile = (file) => {
  815. window.open(file.raw.fileUrl, "_blank");
  816. };
  817. const submitHandoverSlip = () => {
  818. if (
  819. handoverSlipForm.value.fileList &&
  820. handoverSlipForm.value.fileList.length > 0
  821. ) {
  822. for (let i = 0; i < handoverSlipForm.value.fileList.length; i++) {
  823. if (handoverSlipForm.value.fileList[i].raw.uploadState) {
  824. return ElMessage("文件上传中,请稍后提交");
  825. }
  826. }
  827. }
  828. if (
  829. handoverSlipForm.value.packageFileList &&
  830. handoverSlipForm.value.packageFileList.length > 0
  831. ) {
  832. for (let i = 0; i < handoverSlipForm.value.packageFileList.length; i++) {
  833. if (handoverSlipForm.value.packageFileList[i].raw.uploadState) {
  834. return ElMessage("文件上传中,请稍后提交");
  835. }
  836. }
  837. }
  838. let data = proxy.deepClone(handoverSlipForm.value);
  839. if (data.fileList && data.fileList.length > 0) {
  840. data.fileList = data.fileList.map((item) => {
  841. return {
  842. id: item.raw.id,
  843. fileName: item.raw.fileName,
  844. fileUrl: item.raw.fileUrl,
  845. };
  846. });
  847. } else {
  848. data.fileList = [];
  849. }
  850. if (data.packageFileList && data.packageFileList.length > 0) {
  851. data.packageFileList = data.packageFileList.map((item) => {
  852. return {
  853. id: item.raw.id,
  854. fileName: item.raw.fileName,
  855. fileUrl: item.raw.fileUrl,
  856. };
  857. });
  858. } else {
  859. data.packageFileList = [];
  860. }
  861. proxy.post("/contract/contractHandover", data).then(() => {
  862. ElMessage({
  863. message: "操作成功!",
  864. type: "success",
  865. });
  866. openHandoverSlip.value = false;
  867. getList();
  868. });
  869. };
  870. const addTag = ref("");
  871. const judgeTagSelect = (data, val) => {
  872. if (data && data.length > 0) {
  873. if (data.includes(val)) {
  874. return true;
  875. }
  876. }
  877. return false;
  878. };
  879. const changeTag = (val, item) => {
  880. let data = {
  881. id: item.buyCorporationId,
  882. tag: proxy.deepClone(item.tags),
  883. };
  884. data.tag.push(val);
  885. data.tag = data.tag.join(",");
  886. proxy.post("/customer/editTag", data).then(() => {
  887. ElMessage({
  888. message: "添加成功",
  889. type: "success",
  890. });
  891. item.addTagShow = false;
  892. addTag.value = "";
  893. getList();
  894. });
  895. };
  896. const tagClose = (val, item) => {
  897. let data = {
  898. id: item.buyCorporationId,
  899. tag: proxy.deepClone(item.tags),
  900. };
  901. data.tag = data.tag.filter((row) => row !== val);
  902. if (data.tag && data.tag.length > 0) {
  903. data.tag = data.tag.join(",");
  904. } else {
  905. data.tag = "";
  906. }
  907. proxy.post("/customer/editTag", data).then(() => {
  908. ElMessage({
  909. message: "删除成功",
  910. type: "success",
  911. });
  912. item.addTagShow = false;
  913. addTag.value = "";
  914. getList();
  915. });
  916. };
  917. const showSelect = (item) => {
  918. item.addTagShow = true;
  919. };
  920. const currentContractId = ref("");
  921. const openDetails = (row) => {
  922. // currentContractId.value = row.id;
  923. // openDetailsDialog.value = true;
  924. // 新页面打开方式
  925. // const page = proxy.$router.resolve({
  926. // name: "contractDetails",
  927. // query: {
  928. // currentContractId: row.id,
  929. // },
  930. // });
  931. // window.open(page.href, "_blank");
  932. proxy.$router.push({
  933. name: "contractDetails",
  934. query: {
  935. currentContractId: row.id,
  936. },
  937. });
  938. };
  939. const computeScale = (item) => {
  940. let text = 0;
  941. if (
  942. item.sumClaimMoney &&
  943. Number(item.sumClaimMoney) > 0 &&
  944. item.amountCNY &&
  945. Number(item.amountCNY) > 0
  946. ) {
  947. text = parseFloat(
  948. (Number(item.sumClaimMoney) / Number(item.amountCNY)) * 100
  949. ).toFixed(2);
  950. }
  951. return text + "%";
  952. };
  953. const clickCorporationName = (row) => {
  954. proxy.$router.push({
  955. name: "Portrait",
  956. query: {
  957. id: row.buyCorporationId,
  958. },
  959. });
  960. };
  961. const printObj = ref({
  962. id: "pdfDom",
  963. popTitle: "",
  964. extraCss:
  965. "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  966. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  967. });
  968. const clickAlteration = (row) => {
  969. proxy.$router.push({
  970. path: "/platform_manage/process/processApproval",
  971. query: {
  972. flowKey: "contract_update_flow",
  973. flowName: "销售合同变更流程",
  974. random: proxy.random(),
  975. businessId: row.id,
  976. },
  977. });
  978. };
  979. const PdfDom = ref(null);
  980. const exportExcel = () => {
  981. PdfDom.value.exportExcel();
  982. };
  983. const formData = reactive({
  984. recordsFormData: {},
  985. data: {},
  986. });
  987. const formLoading = ref(false);
  988. const openRecords = ref(false);
  989. const openAddRecords = ref(false);
  990. const recordsLoading = ref(false);
  991. const recordsData = ref([]);
  992. const recordsForm = ref(null);
  993. const rowContractData = ref({});
  994. const recordsFormConfig = computed(() => [
  995. {
  996. type: "date",
  997. itemType: "datetime",
  998. prop: "documentaryTime",
  999. label: "售后时间",
  1000. disabled: false,
  1001. },
  1002. {
  1003. type: "input",
  1004. prop: "documentaryRemark",
  1005. label: "售后记录",
  1006. itemType: "textarea",
  1007. disabled: false,
  1008. },
  1009. {
  1010. type: "slot",
  1011. slotName: "file",
  1012. label: "上传附件",
  1013. },
  1014. ]);
  1015. const recordsRules = ref({
  1016. documentaryTime: [
  1017. { required: true, message: "请选择售后时间", trigger: "change" },
  1018. ],
  1019. documentaryRemark: [
  1020. { required: true, message: "请输入售后记录", trigger: "blur" },
  1021. ],
  1022. });
  1023. const getRecordsData = (row) => {
  1024. if (row && row.id) {
  1025. rowContractData.value = row;
  1026. }
  1027. proxy
  1028. .post("/contractDocumentary/page", {
  1029. businessId: rowContractData.value.id,
  1030. documentaryType: "-2",
  1031. })
  1032. .then((res) => {
  1033. recordsData.value = res.rows;
  1034. const idList = recordsData.value.map((x) => x.id);
  1035. // 请求文件数据并回显
  1036. if (idList.length > 0) {
  1037. proxy
  1038. .post("/fileInfo/getList", {
  1039. businessIdList: idList,
  1040. })
  1041. .then((fileObj) => {
  1042. if (fileObj) {
  1043. for (let i = 0; i < recordsData.value.length; i++) {
  1044. const e = recordsData.value[i];
  1045. for (const key in fileObj) {
  1046. if (e.id === key) {
  1047. e.fileList = fileObj[key];
  1048. }
  1049. }
  1050. }
  1051. }
  1052. });
  1053. }
  1054. });
  1055. };
  1056. const handleClickAddRecord = () => {
  1057. formData.recordsFormData = {
  1058. businessId: rowContractData.value.id,
  1059. businessType: "0",
  1060. documentaryType: "-2",
  1061. documentaryTime: proxy.parseTime(new Date()),
  1062. documentaryRemark: "",
  1063. fileList: [],
  1064. };
  1065. openAddRecords.value = true;
  1066. };
  1067. const submitRecords = () => {
  1068. recordsForm.value.handleSubmit(() => {
  1069. formLoading.value = true;
  1070. formData.recordsFormData.fileList = formData.recordsFormData.fileList.map(
  1071. (item) => {
  1072. return {
  1073. id: item.raw.id,
  1074. fileName: item.raw.fileName,
  1075. fileUrl: item.raw.fileUrl,
  1076. uploadState: item.raw.uploadState,
  1077. };
  1078. }
  1079. );
  1080. proxy
  1081. .post("/contractDocumentary/add", formData.recordsFormData)
  1082. .then((res) => {
  1083. ElMessage({
  1084. message: "操作成功",
  1085. type: "success",
  1086. });
  1087. formLoading.value = false;
  1088. openAddRecords.value = false;
  1089. getRecordsData();
  1090. });
  1091. });
  1092. };
  1093. const openFile = (item) => {
  1094. window.open(item.fileUrl, "_blank");
  1095. };
  1096. const formSearchConfig = computed(() => {
  1097. return [
  1098. {
  1099. type: "select",
  1100. label: "审批状态",
  1101. prop: "status",
  1102. itemWidth: 50,
  1103. data: status.value,
  1104. clearable: true,
  1105. },
  1106. {
  1107. type: "select",
  1108. label: "归属公司",
  1109. prop: "companyId",
  1110. itemWidth: 50,
  1111. data: companyData.value,
  1112. clearable: true,
  1113. },
  1114. {
  1115. type: "select",
  1116. label: "业务员",
  1117. prop: "userId",
  1118. data: userList.value,
  1119. clearable: true,
  1120. },
  1121. {
  1122. type: "date",
  1123. itemType: "datetime",
  1124. label: "合同时间",
  1125. prop: "beginTime",
  1126. placeholder: "合同开始时间",
  1127. itemWidth: 50,
  1128. clearable: true,
  1129. },
  1130. {
  1131. type: "date",
  1132. itemType: "datetime",
  1133. label: " ",
  1134. prop: "endTime",
  1135. placeholder: "合同结束时间",
  1136. itemWidth: 50,
  1137. clearable: true,
  1138. },
  1139. ];
  1140. });
  1141. const moreSearchDialog = ref(false);
  1142. const clickMoreSearch = () => {
  1143. moreSearchDialog.value = true;
  1144. };
  1145. const moreSearchQuery = () => {
  1146. moreSearchDialog.value = false;
  1147. getList();
  1148. };
  1149. const moreSearchReset = () => {
  1150. sourceList.value.pagination = {
  1151. total: 0,
  1152. pageNum: sourceList.value.pagination.pageNum,
  1153. pageSize: sourceList.value.pagination.pageSize,
  1154. keyword: "",
  1155. status: "",
  1156. sellCorporationId: "",
  1157. beginTime: "",
  1158. endTime: "",
  1159. };
  1160. moreSearchQuery();
  1161. };
  1162. const productionFormDom = ref(null);
  1163. const productionDialog = ref(false);
  1164. const productionFormConfig = computed(() => [
  1165. {
  1166. type: "treeSelect",
  1167. prop: "produceCompanyId",
  1168. label: "生产公司",
  1169. data: companyData.value,
  1170. propsTreeLabel: "deptName",
  1171. propsTreeValue: "deptId",
  1172. itemWidth: 100,
  1173. // disabled: companyId.value != "100",
  1174. },
  1175. {
  1176. type: "date",
  1177. itemType: "datetime",
  1178. label: "交期",
  1179. prop: "deliveryPeriod",
  1180. // placeholder: "合同开始时间",
  1181. itemWidth: 100,
  1182. clearable: true,
  1183. },
  1184. ]);
  1185. const productionRules = ref({
  1186. produceCompanyId: [
  1187. { required: true, message: "请选择生产公司", trigger: "change" },
  1188. ],
  1189. deliveryPeriod: [
  1190. { required: true, message: "请选择交期", trigger: "change" },
  1191. ],
  1192. });
  1193. const clickDistributeProduction = (row) => {
  1194. formData.data = {
  1195. contractId: row.id,
  1196. deliveryPeriod: "",
  1197. produceCompanyId: "",
  1198. };
  1199. productionDialog.value = true;
  1200. };
  1201. const submitProduction = () => {
  1202. productionFormDom.value.handleSubmit(() => {
  1203. formLoading.value = true;
  1204. proxy.post("/produceOrder/createOrder", formData.data).then((res) => {
  1205. proxy.msgTip("操作成功");
  1206. formLoading.value = false;
  1207. productionDialog.value = false;
  1208. // getList();
  1209. });
  1210. });
  1211. };
  1212. </script>
  1213. <style lang="scss" scoped>
  1214. .tenant {
  1215. padding: 20px;
  1216. }
  1217. ::v-deep(.el-input-number .el-input__inner) {
  1218. text-align: left;
  1219. }
  1220. .baseRow {
  1221. min-height: 24px;
  1222. border-top: 1px solid black;
  1223. border-left: 1px solid black;
  1224. }
  1225. .contentRow {
  1226. border-right: 1px solid black;
  1227. line-height: 24px;
  1228. padding-left: 4px;
  1229. }
  1230. .active {
  1231. background: #a6dd82;
  1232. color: #fff;
  1233. border-radius: 4px;
  1234. }
  1235. </style>