list.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. <template>
  2. <div class="page-indent-list py-4 px-2 shadow max-w-[1800px] mx-auto">
  3. <el-form
  4. ref="searchForm"
  5. v-loading="loading"
  6. :inline="true"
  7. :model="form"
  8. label-width="120px"
  9. >
  10. <div class="flex flex-wrap items-center search-form">
  11. <el-form-item :label="$t(prefix + 'label_project_name') + ':'">
  12. <el-input v-model="form.deal_name"></el-input>
  13. </el-form-item>
  14. <el-form-item :label="$t(prefix + 'label_customer_name') + ':'">
  15. <el-input v-model="form.custom_name"></el-input>
  16. </el-form-item>
  17. <el-form-item :label="$t(prefix + 'label_product_name') + ':'">
  18. <el-input v-model="form.product_name"></el-input>
  19. </el-form-item>
  20. <el-form-item
  21. :label="$t(prefix + 'label_supplier_product') + ':'"
  22. label-width="130px"
  23. >
  24. <el-input
  25. v-model="form.enquiry_product_name"
  26. style="width: 180px"
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item :label="$t(prefix + 'label_category') + ':'">
  30. <el-select v-model="form.product_category">
  31. <el-option
  32. v-for="item in categoryOptions"
  33. :key="item.value"
  34. :label="item.label"
  35. :value="item.value"
  36. ></el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item :label="$t(prefix + 'label_supplier') + ':'">
  40. <el-input v-model="form.vendor_name"></el-input>
  41. </el-form-item>
  42. <el-form-item :label="$t(prefix + 'label_print_method') + ':'">
  43. <el-select v-model="form.print_method">
  44. <el-option
  45. v-for="item in printOptions"
  46. :key="item.value"
  47. :label="item.label"
  48. :value="item.value"
  49. ></el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item :label="$t(prefix + 'label_require_material') + ':'">
  53. <el-select v-model="form.require_material">
  54. <el-option
  55. v-for="item in materialOptions"
  56. :key="item.value"
  57. :label="item.label"
  58. :value="item.value"
  59. ></el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="SKU: ">
  63. <el-input v-model="form.product_sku"></el-input>
  64. </el-form-item>
  65. <el-form-item :label="$t(prefix + 'label_number') + ':'">
  66. <div class="flex justify-between items-center">
  67. <el-input
  68. v-model="form.number_min"
  69. style="width: 80px"
  70. ></el-input>
  71. <span>&nbsp;-&nbsp;</span>
  72. <el-input
  73. v-model="form.number_max"
  74. style="width: 80px"
  75. ></el-input>
  76. </div>
  77. </el-form-item>
  78. <el-form-item
  79. :label="$t('table_created_time') + ':'"
  80. label-width="100px"
  81. >
  82. <el-date-picker
  83. v-model="form.date_range"
  84. style="width: 210px; padding-right: 0"
  85. format="YYYY-MM-DD"
  86. value-format="YYYY-MM-DD"
  87. type="daterange"
  88. range-separator="~"
  89. :start-placeholder="$t(prefix + 'ph_time_start')"
  90. :end-placeholder="$t(prefix + 'ph_time_end')"
  91. ></el-date-picker>
  92. </el-form-item>
  93. <el-form-item :label="$t(prefix + 'label_quoter') + ':'">
  94. <el-select
  95. v-model="form.creator"
  96. filterable
  97. >
  98. <el-option
  99. v-for="item in creatorOptions"
  100. :key="item.value"
  101. :label="item.label"
  102. :value="item.value"
  103. ></el-option>
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item :label="$t(prefix + 'label_status') + ':'">
  107. <el-select v-model="form.status">
  108. <el-option
  109. v-for="item in stateOptions"
  110. :key="item.value"
  111. :label="item.label"
  112. :value="item.value"
  113. ></el-option>
  114. </el-select>
  115. </el-form-item>
  116. <div class="flex items-center btn-group">
  117. <el-button
  118. type="primary"
  119. @click="search"
  120. >
  121. {{ $t('btn_search') }}
  122. </el-button>
  123. <el-button
  124. type="success"
  125. @click="create"
  126. >
  127. {{ $t(prefix + 'btn_new_indent') }}
  128. </el-button>
  129. <el-button
  130. :disabled="checkedQuotes.length < 1"
  131. type="primary"
  132. @click="quota"
  133. >
  134. {{ $t(prefix + 'btn_quote') }}
  135. </el-button>
  136. <el-button
  137. :disabled="checkedIndent.length < 1 && checkedQuotes.length < 1"
  138. type="danger"
  139. @click="onDeleteIndent"
  140. >
  141. {{ $t('btn_delete') }}
  142. </el-button>
  143. <el-button @click="reset">
  144. {{ $t('btn_reset') }}
  145. </el-button>
  146. <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  147. <el-button
  148. type="warning"
  149. @click="componentFreightVisible = true"
  150. >
  151. {{ $t(prefix + 'btn_set_freight') }}
  152. </el-button>
  153. </div>
  154. </div>
  155. </el-form>
  156. <el-table
  157. ref="tableIndent"
  158. v-loading="loading"
  159. :header-cell-style="{ backgroundColor: '#F2F6FC' }"
  160. :row-style="{ backgroundColor: '#F2F6FC' }"
  161. :data="indentList"
  162. default-expand-all
  163. border
  164. >
  165. <!-- 子表格内容 -->
  166. <el-table-column type="expand">
  167. <template #default="props">
  168. <el-table
  169. v-if="props.row.lists && props.row.lists.length"
  170. :ref="`tableSubIndent-${props.row.id}`"
  171. :data="props.row.lists"
  172. class="tableSubIndent"
  173. :class="`tableSubIndent-${props.row.id}`"
  174. :row-class-name="
  175. ({ row }) => {
  176. return props.row.default_quote === row.id
  177. ? 'default-quote-row'
  178. : 'ddd-ddd'
  179. }
  180. "
  181. style="margin-left: 48px"
  182. stripe
  183. border
  184. >
  185. <el-table-column
  186. v-for="value in subTableConfig"
  187. :key="value.field"
  188. :align="value.align || 'center'"
  189. :width="value.width || ''"
  190. :prop="value.field"
  191. :label="$t(value.label)"
  192. >
  193. <template #default="scope">
  194. <div v-if="value.type === 'checkbox'">
  195. <el-checkbox
  196. v-model="scope.row[value.field]"
  197. @change="($e) => onSubSelect($e, props.row)"
  198. ></el-checkbox>
  199. </div>
  200. <div
  201. v-else-if="value.type === 'imageList'"
  202. class="table-img-wrap"
  203. :style="{
  204. width: `${Number(value.width) - 20}px`,
  205. }"
  206. >
  207. <el-tooltip content="点击可查看大图">
  208. <img
  209. style="width: 100%; cursor: pointer"
  210. :src="scope.row[value.field][0]"
  211. @click="imgClick(scope.row[value.field][0])"
  212. />
  213. </el-tooltip>
  214. </div>
  215. <div
  216. v-else-if="value.field === 'vendor_name'"
  217. style="text-align: left"
  218. >
  219. <div>{{ scope.row[value.field] }}</div>
  220. <div v-show="scope.row.vendor_contact">
  221. 联系人:&nbsp;{{ scope.row.vendor_contact }}
  222. </div>
  223. <div v-show="scope.row.vendor_phone">
  224. 联系电话:&nbsp;{{ scope.row.vendor_phone }}
  225. </div>
  226. </div>
  227. <el-tooltip
  228. v-else
  229. :content="$t(value.label)"
  230. >
  231. <div
  232. class="table-cell-content"
  233. :style="value.style || {}"
  234. >
  235. {{ scope.row[value.field] }}
  236. </div>
  237. </el-tooltip>
  238. </template>
  239. </el-table-column>
  240. <el-table-column
  241. prop="status"
  242. width="280"
  243. :label="$t('table_operation')"
  244. >
  245. <template #default="scope">
  246. <el-button
  247. size="small"
  248. type="warning"
  249. @click="editInfo(scope.row)"
  250. >
  251. {{ $t('btn_edit') }}
  252. </el-button>
  253. <el-button
  254. size="small"
  255. type="primary"
  256. @click="valuation(scope.row)"
  257. >
  258. {{ $t(prefix + 'btn_calc_price') }}
  259. </el-button>
  260. <el-button
  261. v-if="props.row.default_quote !== scope.row.id"
  262. size="small"
  263. type="success"
  264. :disabled="props.row.default_quote === scope.row.id"
  265. @click="adopt(scope.row, props.row)"
  266. >
  267. {{
  268. props.row.default_quote === scope.row.id
  269. ? $t(prefix + 'btn_adopted')
  270. : $t(prefix + 'btn_adopt')
  271. }}
  272. </el-button>
  273. <el-button
  274. v-if="props.row.default_quote === scope.row.id"
  275. size="small"
  276. type="warning"
  277. @click="onBtnChangeOrderClick(scope.row, props.row)"
  278. >
  279. 转单
  280. </el-button>
  281. </template>
  282. </el-table-column>
  283. </el-table>
  284. <div
  285. v-else
  286. class="flex justify-center items-center"
  287. >
  288. <div>暂无报价</div>
  289. </div>
  290. </template>
  291. </el-table-column>
  292. <!-- 子表格内容 end -->
  293. <!-- 主表格 内容 -->
  294. <el-table-column
  295. v-for="value in mainTableConfig"
  296. :key="value.field"
  297. :align="value.align || 'center'"
  298. :width="value.width || ''"
  299. :prop="value.field"
  300. :label="$t(value.label)"
  301. >
  302. <template
  303. v-if="value.type === 'checkbox'"
  304. #header
  305. >
  306. <el-checkbox
  307. v-model="checkedAll"
  308. @change="onSelectAll"
  309. ></el-checkbox>
  310. </template>
  311. <template #default="scope">
  312. <div v-if="value.type === 'checkbox'">
  313. <el-checkbox
  314. v-model="scope.row[value.field]"
  315. @change="($e) => onSelect($e, scope.$index)"
  316. ></el-checkbox>
  317. </div>
  318. <el-tooltip
  319. v-else-if="value.field === 'quote_name'"
  320. :content="$t(value.label) + ', 双击可编辑'"
  321. >
  322. <div
  323. class="table-cell-content"
  324. :style="value.style || {}"
  325. @dblclick="onEdit(scope.row)"
  326. >
  327. {{ scope.row[value.field] }}
  328. </div>
  329. </el-tooltip>
  330. <el-tooltip
  331. v-else
  332. :content="$t(value.label)"
  333. >
  334. <div
  335. class="table-cell-content"
  336. :style="value.style || {}"
  337. >
  338. {{ scope.row[value.field] }}
  339. </div>
  340. </el-tooltip>
  341. </template>
  342. </el-table-column>
  343. </el-table>
  344. <div class="flex justify-end my-4">
  345. <el-pagination
  346. v-show="total > 0"
  347. v-model:current-page="pageForm.page"
  348. v-model:page-size="pageForm.limit"
  349. v-model:total="total"
  350. layout="prev, pager, next, jumper, sizes"
  351. @current-change="getList"
  352. @size-change="getList"
  353. />
  354. </div>
  355. <edit
  356. v-model:visible="componentEditVisible"
  357. :indent-data="indentData"
  358. :quota-data="quotaData"
  359. :category-options="categoryOptions"
  360. :print-options="printOptions"
  361. :material-options="materialOptions"
  362. @create="getList"
  363. ></edit>
  364. <freight v-model:visible="componentFreightVisible"></freight>
  365. <compEditInfo
  366. v-model:visible="componentEditInfoVisible"
  367. :data-for-edit="quoteForEdit"
  368. :parent-id="infoParentId"
  369. @create="getList"
  370. ></compEditInfo>
  371. <calcPrice
  372. v-model:visible="componentCalcPriceVisible"
  373. :creator-options="creatorOptions"
  374. :data-for-calc="quoteForEdit"
  375. @save-price-calc="getList"
  376. ></calcPrice>
  377. <el-dialog
  378. v-model="bigImageVisible"
  379. style="margin: 5vh auto"
  380. width="800"
  381. >
  382. <div class="flex justify-center">
  383. <img
  384. :src="currentBigImage"
  385. style="max-width: 100%; height: auto"
  386. alt=""
  387. />
  388. </div>
  389. </el-dialog>
  390. <dialogQuoteRecord
  391. :id="changeOrderID"
  392. :indent-data="indentData"
  393. v-model:visible="dialogChangeOrderVisible"
  394. @success="onDialogChangeOrderClose"
  395. ></dialogQuoteRecord>
  396. </div>
  397. </template>
  398. <script setup lang="ts">
  399. import { defineComponent, ref, computed, watch, inject } from 'vue'
  400. import {
  401. ElButton,
  402. ElForm,
  403. ElFormItem,
  404. ElInput,
  405. ElTable,
  406. ElTableColumn,
  407. ElSelect,
  408. ElOption,
  409. ElMessageBox,
  410. ElTooltip,
  411. ElNotification,
  412. ElPagination,
  413. ElDatePicker,
  414. ElCheckbox,
  415. ElDialog,
  416. } from 'element-plus'
  417. import { $t } from '@/i18n/index'
  418. import {
  419. getIndentList,
  420. getCreator,
  421. deleteIndent,
  422. cloneQuote,
  423. setDefaultQuote,
  424. } from '@/api/indent'
  425. import userAPI from '@/api/user'
  426. import edit from './edit.vue'
  427. import freight from './components/freight.vue'
  428. import compEditInfo from './components/info.vue'
  429. import calcPrice from './components/calcPrice/index.vue'
  430. import dialogQuoteRecord from './components/quoteRecord.vue'
  431. defineComponent({
  432. name: 'PageIndentList',
  433. })
  434. const $mediaRegExp = inject('mediaRegExp') as RegExp
  435. const prefix = 'order.indent.'
  436. const form = ref({
  437. product_name: '',
  438. product_sku: '',
  439. deal_name: '',
  440. custom_name: '',
  441. product_category: '',
  442. require_material: '',
  443. print_method: '',
  444. date_range: [],
  445. creator: '',
  446. enquiry_product_name: '',
  447. vendor_name: '',
  448. number_min: '',
  449. number_max: '',
  450. status: '',
  451. })
  452. const total = ref(0)
  453. const pageForm = ref({
  454. page: 1,
  455. limit: 20,
  456. })
  457. const categoryOptions = [
  458. {
  459. label: $t('text_please_select'),
  460. value: '',
  461. },
  462. {
  463. label: 'Lanyards',
  464. value: 'Lanyards',
  465. },
  466. {
  467. label: 'PIN BADGES',
  468. value: 'PIN BADGES',
  469. },
  470. {
  471. label: 'WRISTBANDS',
  472. value: 'WRISTBANDS',
  473. },
  474. {
  475. label: 'KEYRINGS',
  476. value: 'KEYRINGS',
  477. },
  478. {
  479. label: 'NEOPRENE',
  480. value: 'NEOPRENE',
  481. },
  482. {
  483. label: 'STATIONERY',
  484. value: 'STATIONERY',
  485. },
  486. {
  487. label: 'LIFESTYLE',
  488. value: 'LIFESTYLE',
  489. },
  490. {
  491. label: 'POS',
  492. value: 'POS',
  493. },
  494. {
  495. label: '其它',
  496. value: '其它',
  497. },
  498. ]
  499. const printOptions = [
  500. {
  501. label: $t('text_please_select'),
  502. value: '',
  503. },
  504. {
  505. label: '全彩印刷',
  506. value: '全彩印刷',
  507. },
  508. {
  509. label: '专色印刷',
  510. value: '专色印刷',
  511. },
  512. {
  513. label: '热转印',
  514. value: '热转印',
  515. },
  516. {
  517. label: '丝印',
  518. value: '丝印',
  519. },
  520. {
  521. label: '镭雕',
  522. value: '镭雕',
  523. },
  524. {
  525. label: '凹印',
  526. value: '凹印',
  527. },
  528. {
  529. label: '刺绣',
  530. value: '刺绣',
  531. },
  532. {
  533. label: '其它',
  534. value: '其它',
  535. },
  536. ]
  537. const materialOptions = [
  538. {
  539. label: $t('text_please_select'),
  540. value: '',
  541. },
  542. {
  543. label: '布料',
  544. value: '布料',
  545. },
  546. {
  547. label: '塑料',
  548. value: '塑料',
  549. },
  550. {
  551. label: '纸质',
  552. value: '纸质',
  553. },
  554. {
  555. label: '五金',
  556. value: '五金',
  557. },
  558. {
  559. label: '其它',
  560. value: '其它',
  561. },
  562. ]
  563. const stateOptions = [
  564. {
  565. label: '全部',
  566. value: '',
  567. },
  568. {
  569. label: '未报价',
  570. value: '0',
  571. },
  572. {
  573. label: '已报价',
  574. value: '1',
  575. },
  576. ]
  577. const mainTableConfig: any[] = [
  578. {
  579. type: 'checkbox',
  580. field: 'checked',
  581. width: '55',
  582. },
  583. {
  584. label: 'Reference',
  585. field: 'Reference',
  586. width: '110',
  587. },
  588. {
  589. label: 'order.indent.table_indent_name',
  590. field: 'quote_name',
  591. style: 'cursor: default',
  592. },
  593. {
  594. label: 'order.indent.label_project_name',
  595. field: 'deal_name',
  596. width: '120',
  597. },
  598. {
  599. label: 'order.indent.label_customer_name',
  600. field: 'custom_name',
  601. width: '180',
  602. },
  603. {
  604. label: 'order.indent.label_product_name',
  605. field: 'product_name',
  606. },
  607. {
  608. label: 'order.indent.label_status',
  609. field: 'status',
  610. width: '80',
  611. style: 'font-weight: bold;',
  612. },
  613. {
  614. label: 'order.indent.table_creator',
  615. field: 'creator',
  616. width: '90',
  617. style: 'font-weight: bold;',
  618. },
  619. {
  620. label: 'table_created_time',
  621. field: 'create_time',
  622. width: '120',
  623. },
  624. ]
  625. const subTableConfig: any = [
  626. {
  627. type: 'checkbox',
  628. field: 'checked',
  629. width: '55',
  630. },
  631. {
  632. label: 'order.indent.table_image',
  633. type: 'imageList',
  634. width: '80',
  635. field: 'product_image',
  636. },
  637. {
  638. label: 'order.indent.table_supplier',
  639. field: 'vendor_name',
  640. },
  641. {
  642. label: 'order.indent.table_url',
  643. field: 'product_url',
  644. },
  645. {
  646. label: 'order.indent.table_price',
  647. field: 'quote_price',
  648. width: '75',
  649. },
  650. {
  651. label: 'order.indent.label_number',
  652. field: 'quote_num',
  653. width: '150',
  654. },
  655. {
  656. label: 'order.indent.table_days',
  657. field: 'large_days',
  658. width: '90',
  659. },
  660. {
  661. label: 'order.indent.label_quoter',
  662. field: 'creator',
  663. width: '90',
  664. style: 'font-weight: bold;',
  665. },
  666. {
  667. label: 'table_updated_time',
  668. field: 'update_time',
  669. width: '115',
  670. },
  671. ]
  672. const componentEditVisible = ref(0) // 1 新增, 2编辑. 0关闭
  673. const componentFreightVisible = ref(false) // 设置运费参数
  674. const componentEditInfoVisible = ref(0) // 编辑报价信息
  675. const componentCalcPriceVisible = ref(false) // 计价
  676. const indentData = ref({}) // 修改询价和转单的时候使用, 记录的是询价的行数据.
  677. const quoteForEdit = ref({}) // 修改和计价时共用, 只是用作传递给子组件数据的变量
  678. const infoParentId = ref(0)
  679. const loading = ref(false)
  680. const checkedAll = ref(false)
  681. const quotaData = ref({}) // 引用报价信息后得到的克隆数据, 传递给创建询价组件, 当作新创建的报价信息.
  682. const indentList = ref([] as any[])
  683. const checkedQuotes = computed(() => {
  684. return indentList.value.reduce((total: any, current: any) => {
  685. if (current.lists?.length) {
  686. current.lists.forEach((i: any) => {
  687. if (i.checked) {
  688. total.push(i)
  689. }
  690. })
  691. }
  692. return total
  693. }, [])
  694. })
  695. const checkedIndent = computed(() => {
  696. return indentList.value.filter((i: any) => i.checked)
  697. })
  698. const getList = function () {
  699. quotaData.value = {} // 重置引用数据, 否则创建询价完成之后再次创建询价, 会把之前的引用数据再次带到创建询价组件
  700. const timeSeparator = '~'
  701. const temp = JSON.parse(JSON.stringify(form.value))
  702. const p = Object.assign({}, temp, pageForm.value)
  703. // 组装日期范围数据
  704. if (Array.isArray(p.date_range) && p.date_range.length) {
  705. p.date_range = p.date_range.join(timeSeparator)
  706. } else {
  707. p.date_range = ''
  708. }
  709. loading.value = true
  710. // const getlist = function () {
  711. getIndentList(p)
  712. .then((res: any) => {
  713. indentList.value =
  714. res.result?.data.map((main: any) => {
  715. return {
  716. ...main,
  717. create_time: main.create_time.split(' ')[0],
  718. checked: false,
  719. lists: main.lists.map((i: any) => {
  720. const temp = { ...i, checked: false }
  721. if (
  722. Array.isArray(temp.product_image) &&
  723. temp.product_image.length
  724. ) {
  725. temp.product_image = temp.product_image.map((img: string) =>
  726. $mediaRegExp.test(img)
  727. ? img
  728. : import.meta.env.VITE_APP_OSS_PREFIX + img,
  729. )
  730. } else {
  731. temp.product_image = []
  732. }
  733. return temp
  734. }),
  735. }
  736. }) || []
  737. total.value = res.result.total
  738. })
  739. .finally(() => {
  740. loading.value = false
  741. })
  742. }
  743. const creatorOptions = ref([] as any[])
  744. // 获取报价人下拉框候选数据.
  745. const getCreatorOption = function () {
  746. getCreator().then((res: any) => {
  747. creatorOptions.value = res.result.map((i: any) => {
  748. return { label: i.username, value: i.id }
  749. })
  750. creatorOptions.value.unshift({
  751. label: $t(prefix + 'ph_quoter'),
  752. value: '',
  753. })
  754. })
  755. }
  756. const search = function () {
  757. pageForm.value = {
  758. page: 1,
  759. limit: 20,
  760. }
  761. getList()
  762. }
  763. const create = function () {
  764. componentEditVisible.value = 1
  765. }
  766. const onEdit = function (row: any) {
  767. quotaData.value = {}
  768. indentData.value = row
  769. componentEditVisible.value = 2
  770. }
  771. const quota = function () {
  772. const ids = checkedQuotes.value.map((i: any) => i.id)
  773. cloneQuote({ ids }).then((response: any) => {
  774. if (response.code === 1) {
  775. quotaData.value = response.result
  776. create()
  777. }
  778. })
  779. }
  780. const onDeleteIndent = function () {
  781. ElMessageBox.confirm('将删除该报价, 是否继续?', '提示', {
  782. confirmButtonText: '确定',
  783. cancelButtonText: '取消',
  784. type: 'warning',
  785. }).then(() => {
  786. const p = {
  787. indent_ids: checkedIndent.value.map((i: any) => `${i.id}`), // 询价id
  788. quote_ids: checkedQuotes.value.map((i: any) => `${i.parent_id}_${i.id}`), // 报价id数据. 单个格式为 '询价id_报价id'
  789. }
  790. deleteIndent(p).then((response: any) => {
  791. if (response.code === 1) {
  792. getList()
  793. ElNotification({
  794. title: '删除成功',
  795. message: '删除成功',
  796. duration: 3000,
  797. })
  798. }
  799. })
  800. })
  801. }
  802. const reset = function () {
  803. form.value = {
  804. product_name: '',
  805. product_sku: '',
  806. deal_name: '',
  807. custom_name: '',
  808. product_category: '',
  809. require_material: '',
  810. print_method: '',
  811. date_range: [],
  812. creator: '',
  813. enquiry_product_name: '',
  814. vendor_name: '',
  815. number_min: '',
  816. number_max: '',
  817. status: '',
  818. }
  819. pageForm.value = {
  820. page: 1,
  821. limit: 20,
  822. }
  823. total.value = 0
  824. getList()
  825. }
  826. const editInfo = function (row: any) {
  827. infoParentId.value = row.parent_id
  828. quoteForEdit.value = row
  829. componentEditInfoVisible.value = 2
  830. }
  831. // 计价
  832. const valuation = function (row: any) {
  833. quoteForEdit.value = row
  834. componentCalcPriceVisible.value = true
  835. }
  836. // 采纳
  837. const adopt = function (row: any, parentRow: any) {
  838. const p = {
  839. id: parentRow.id,
  840. quote_id: row.id,
  841. }
  842. setDefaultQuote(p).then((res: any) => {
  843. if (res.code === 1) {
  844. ElNotification({
  845. type: 'success',
  846. title: '操作成功',
  847. message: '正在刷新数据',
  848. duration: 3000,
  849. })
  850. } else {
  851. ElNotification({
  852. type: 'error',
  853. title: '操作出错了',
  854. message: '请稍后重试, 或者联系管理员',
  855. duration: 3000,
  856. })
  857. }
  858. getList()
  859. })
  860. }
  861. const onSelect = function (bool: any, index: number) {
  862. // console.log('onSelect', bool, index)
  863. // 每次勾选主表的某行, 立刻计算主表的全选
  864. checkedAll.value = indentList.value.every((i) => i.checked)
  865. // 勾选主表格的某行, 将该行所属的 子表格 给全部勾选/取消勾选
  866. indentList.value[index].lists = indentList.value[index].lists.map(
  867. (i: any) => {
  868. return {
  869. ...i,
  870. checked: bool,
  871. }
  872. },
  873. )
  874. }
  875. // 主表格全勾选, 遍历数据将所有子表格全勾选
  876. const onSelectAll = function (boolean: any) {
  877. // console.log('onSelectAll', boolean)
  878. indentList.value = indentList.value.map((i: any) => {
  879. return {
  880. ...i,
  881. checked: boolean,
  882. lists: i.lists.map((j: any) => {
  883. return {
  884. ...j,
  885. checked: boolean,
  886. }
  887. }),
  888. }
  889. })
  890. }
  891. // 勾选子表格的某行
  892. const onSubSelect = function (bool: any, row: any) {
  893. // console.log('onSelect-sub', bool, row)
  894. // 判断该行对应 在主表的父行 的勾选状态
  895. row.checked = row.lists.every((i: any) => i.checked)
  896. // 变更主表某行的勾选状态后, 立刻计算主表的全选
  897. checkedAll.value = indentList.value.every((i: any) => i.checked)
  898. }
  899. getList()
  900. getCreatorOption()
  901. const currentBigImage = ref('')
  902. const bigImageVisible = ref(false)
  903. const imgClick = (url: string) => {
  904. currentBigImage.value = url
  905. bigImageVisible.value = true
  906. }
  907. watch(bigImageVisible, () => {
  908. if (!bigImageVisible.value) currentBigImage.value = ''
  909. })
  910. const changeOrderID = ref('')
  911. const dialogChangeOrderVisible = ref(false)
  912. const onBtnChangeOrderClick = (row: any, parentRow: any) => {
  913. // console.log(row, 'row', parentRow, 'parentRow')
  914. if (['Temporary Indent Product', '申请中'].includes(parentRow.product_sku)) {
  915. ElNotification({
  916. type: 'warning',
  917. title: '提示',
  918. message: `SKU在申请中无法直接转单, 需要联系: ${auditUser.value}`,
  919. duration: 6000,
  920. })
  921. } else {
  922. if (parentRow.crm_so_id) {
  923. ElMessageBox.confirm(
  924. '当前报价已转单, 如果二次转单将会全面覆盖之前的SO',
  925. '提示',
  926. {
  927. confirmButtonText: '确定重新转单',
  928. cancelButtonText: '取消',
  929. type: 'warning',
  930. },
  931. ).then(() => {
  932. changeOrderID.value = row.id
  933. indentData.value = parentRow
  934. dialogChangeOrderVisible.value = true
  935. })
  936. } else {
  937. changeOrderID.value = row.id
  938. indentData.value = parentRow
  939. dialogChangeOrderVisible.value = true
  940. }
  941. }
  942. }
  943. const onDialogChangeOrderClose = () => {
  944. getList()
  945. dialogChangeOrderVisible.value = false
  946. changeOrderID.value = ''
  947. indentData.value = {}
  948. }
  949. watch(dialogChangeOrderVisible, () => {
  950. if (!dialogChangeOrderVisible.value) {
  951. indentData.value = {}
  952. changeOrderID.value = ''
  953. }
  954. })
  955. const auditUser = ref('')
  956. const getCurrentAuditUser = () => {
  957. userAPI.getAuditUser().then((res: any) => {
  958. // console.log(res, 'res')
  959. if (
  960. res.code === 1 &&
  961. Array.isArray(res.result.data) &&
  962. res.result.data.length
  963. ) {
  964. const temp = res.result.data.filter((i: any) => i.type === 2)
  965. // console.log(temp, 'temp')
  966. if (temp.length) auditUser.value = temp[0].email
  967. }
  968. })
  969. }
  970. getCurrentAuditUser()
  971. </script>
  972. <style lang="scss">
  973. .page-indent-list {
  974. .default-quote-row {
  975. color: #ef4135;
  976. }
  977. }
  978. </style>
  979. <style lang="scss" scoped>
  980. .search-form {
  981. .el-form-item {
  982. width: 310px;
  983. }
  984. .el-input,
  985. .el-select,
  986. .el-date-editor {
  987. width: 190px;
  988. }
  989. .btn-group {
  990. margin: 0 0 22px 8px;
  991. }
  992. }
  993. .table-cell-content {
  994. word-break: break-word;
  995. }
  996. </style>