index.vue 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993
  1. <template>
  2. <el-card shadow="always" :body-style="{ padding: '10px' }">
  3. <div class="app-container">
  4. <el-dialog
  5. :title="upload.title"
  6. :visible.sync="upload.open"
  7. width="400px"
  8. append-to-body
  9. >
  10. <el-upload
  11. ref="upload"
  12. :limit="1"
  13. accept=".xlsx, .xls"
  14. :headers="upload.headers"
  15. :action="
  16. upload.url +
  17. '?updateSupport=' +
  18. upload.updateSupport +
  19. '&tableName=' +
  20. tableName +
  21. '&sqlKey=' +
  22. tableKey
  23. "
  24. v-loading="upload.isUploading"
  25. :disabled="upload.isUploading"
  26. :on-progress="handleFileUploadProgress"
  27. :on-success="handleFileSuccess"
  28. :auto-upload="false"
  29. :onChange="handleChange"
  30. drag
  31. >
  32. <i class="el-icon-upload"></i>
  33. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  34. <div class="el-upload__tip text-center" slot="tip">
  35. <!-- <div class="el-upload__tip" slot="tip">-->
  36. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  37. <!-- 是否更新已经存在的用户数据-->
  38. <!-- </div>-->
  39. <span>仅允许导入xls、xlsx格式文件。</span>
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. style="font-size: 12px; vertical-align: baseline"
  44. @click="importTemplate"
  45. >下载模板
  46. </el-link>
  47. </div>
  48. </el-upload>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  51. <el-button @click="upload.open = false">取 消</el-button>
  52. </div>
  53. </el-dialog>
  54. <Queryfrom
  55. :form-vals="templateInfo.where"
  56. :statisticList="statisticList"
  57. :showCount="showCount"
  58. :showSearch="showSearch"
  59. @getList="getList"
  60. ref="mychild"
  61. />
  62. <el-row :gutter="10" class="mb8">
  63. <el-col :span="1.5">
  64. <el-button
  65. type="primary"
  66. plain
  67. icon="el-icon-plus"
  68. size="mini"
  69. @click="addHandler"
  70. >新增
  71. </el-button>
  72. </el-col>
  73. <!-- <el-col :span="1.5" v-if="false">
  74. <el-button
  75. type="success"
  76. plain
  77. icon="el-icon-edit"
  78. size="mini"
  79. :disabled="single"
  80. @click="handleUpdate"
  81. >修改
  82. </el-button>
  83. </el-col> -->
  84. <el-col :span="1.5">
  85. <el-button
  86. type="danger"
  87. plain
  88. icon="el-icon-delete"
  89. size="mini"
  90. :disabled="multiple"
  91. @click="myDeleteHandler"
  92. >删除
  93. </el-button>
  94. </el-col>
  95. <!-- <el-col :span="1.5">
  96. <el-button
  97. plain
  98. icon="el-icon-upload2"
  99. size="mini"
  100. @click="upload.open = true"
  101. >导入
  102. </el-button>
  103. </el-col>
  104. <el-col :span="1.5">
  105. <el-button
  106. type="warning"
  107. plain
  108. icon="el-icon-download"
  109. size="mini"
  110. @click="handleExport"
  111. >导出
  112. </el-button>
  113. </el-col>
  114. <right-toolbar
  115. style="float: right"
  116. :showCount.sync="showCount"
  117. :showSearch.sync="showSearch"
  118. :counts="true"
  119. @queryTable="pageList"
  120. ></right-toolbar> -->
  121. </el-row>
  122. <el-table
  123. v-loading="loading"
  124. :data="tableList"
  125. @selection-change="handleSelectionChange"
  126. ref="tableRef"
  127. :cell-style="cellStyle"
  128. :reserve-selection="true"
  129. row-key="saleOrderId"
  130. >
  131. <el-table-column
  132. type="selection"
  133. width="55"
  134. reserve-selection
  135. align="center"
  136. >
  137. </el-table-column>
  138. <!-- <el-table-column type="selection" width="55" /> -->
  139. <el-table-column prop="saleNo" label="合同号" />
  140. <el-table-column prop="saleDate" label="日期" />
  141. <el-table-column prop="customName" label="客户名称" />
  142. <el-table-column prop="deliveryDate" label="交货日期" />
  143. <el-table-column prop="saleLeadTime" label="交货天数" />
  144. <el-table-column prop="saleAmountInWords" label="合计金额(大写)" />
  145. <el-table-column prop="status" label="状态">
  146. <template slot-scope="scope">
  147. <el-tag :type="scope.row.listClass">{{
  148. getDictLabel(scope.row.status, "sales_order_status")
  149. }}</el-tag>
  150. </template>
  151. </el-table-column>
  152. <el-table-column prop="salesman" label="销售员" />
  153. <el-table-column prop="remark" label="备注" />
  154. <el-table-column label="操作">
  155. <template slot-scope="scope">
  156. <el-dropdown>
  157. <el-button type="warning" plain size="small">
  158. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  159. </el-button>
  160. <el-dropdown-menu slot="dropdown">
  161. <el-dropdown-item v-show="scope.row.status == 1">
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-edit"
  166. @click="handleUpdate(scope.row)"
  167. >修改
  168. </el-button>
  169. </el-dropdown-item>
  170. <el-dropdown-item>
  171. <el-button
  172. size="mini"
  173. type="text"
  174. icon="el-icon-tickets"
  175. @click="handlePrint(scope.row)"
  176. >详情
  177. </el-button>
  178. </el-dropdown-item>
  179. <el-dropdown-item v-show="scope.row.status == 1">
  180. <el-button
  181. size="mini"
  182. type="text"
  183. icon="el-icon-folder-checked"
  184. @click="handleSubmit(scope.row)"
  185. >提交
  186. </el-button>
  187. </el-dropdown-item>
  188. <el-dropdown-item v-show="scope.row.status == 5">
  189. <el-button
  190. size="mini"
  191. type="text"
  192. icon="el-icon-folder-delete"
  193. @click="handleSubmitCancel(scope.row)"
  194. >撤销
  195. </el-button>
  196. </el-dropdown-item>
  197. <el-dropdown-item v-show="scope.row.status != 1">
  198. <el-button
  199. size="mini"
  200. type="text"
  201. icon="el-icon-folder-delete"
  202. @click="handleOutDetail(scope.row)"
  203. >出库明细
  204. </el-button>
  205. </el-dropdown-item>
  206. <el-dropdown-item
  207. v-show="
  208. scope.row.status == 1 ||
  209. scope.row.status == 2 ||
  210. scope.row.status == 8
  211. "
  212. >
  213. <el-button
  214. size="mini"
  215. type="text"
  216. icon="el-icon-folder-delete"
  217. @click="myPrintOutBoundHandler(scope.row)"
  218. >打印出库单
  219. </el-button>
  220. </el-dropdown-item>
  221. <el-dropdown-item v-show="scope.row.status == 1">
  222. <el-button
  223. size="mini"
  224. type="text"
  225. icon="el-icon-delete"
  226. @click="handleDelete(scope.row)"
  227. >删除
  228. </el-button>
  229. </el-dropdown-item>
  230. </el-dropdown-menu>
  231. </el-dropdown>
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. <pagination
  236. v-show="total > 0"
  237. :total="total"
  238. :page.sync="queryParams.pageNum"
  239. :limit.sync="queryParams.pageSize"
  240. @pagination="pageList"
  241. />
  242. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  243. <el-dialog
  244. :title="title"
  245. width="1100px"
  246. :visible.sync="open"
  247. append-to-body
  248. >
  249. <el-row :gutter="20">
  250. <el-form
  251. :model="formData"
  252. ref="formDataRef"
  253. :rules="rules"
  254. label-width="100px"
  255. :inline="true"
  256. size="normal"
  257. >
  258. <el-col :span="12">
  259. <el-form-item prop="saleNo" label="合同号:">
  260. <!-- <el-input size="small" v-model="formData.saleNo"></el-input> -->
  261. {{ formData.saleNo }}
  262. </el-form-item>
  263. </el-col>
  264. <!-- <el-col :span="12">
  265. <el-form-item prop="lotNumber" label="批号:">
  266. <el-input size="small" v-model="formData.lotNumber"></el-input>
  267. </el-form-item>
  268. </el-col> -->
  269. <el-col :span="12">
  270. <el-form-item prop="saleDate" label="日期:">
  271. <!-- <el-date-picker
  272. size="small"
  273. v-model="formData.saleDate"
  274. value-format="yyyy-MM-dd"
  275. format="yyyy-MM-dd"
  276. type="date"
  277. placeholder="选择日期"
  278. >
  279. </el-date-picker> -->
  280. {{ formData.saleDate }}
  281. </el-form-item>
  282. </el-col>
  283. <el-col :span="12">
  284. <el-form-item prop="saleCustomNo" label="客户名称:">
  285. <el-select
  286. size="small"
  287. v-model="formData.saleCustomNo"
  288. placeholder="请选择客户"
  289. clearable
  290. filterable
  291. @change="customChangeHandler"
  292. >
  293. <el-option
  294. v-for="item in customerOptions"
  295. :key="item.customNo"
  296. :label="item.customName"
  297. :value="item.customNo"
  298. >
  299. </el-option>
  300. </el-select>
  301. </el-form-item>
  302. </el-col>
  303. <el-col :span="12">
  304. <el-form-item v-if="isLeader" label="业务员:">
  305. <el-select
  306. size="small"
  307. v-model="formData.salesman"
  308. placeholder="请选择业务员"
  309. clearable
  310. filterable
  311. @change="salemanChange"
  312. >
  313. <el-option
  314. v-for="item in salesmanList"
  315. :key="item.value"
  316. :label="item.label"
  317. :value="item.value"
  318. >
  319. </el-option>
  320. </el-select>
  321. </el-form-item>
  322. <el-form-item v-else label="业务员:">
  323. <!-- <el-input
  324. v-model="formData.salesman"
  325. size="small"
  326. clearable
  327. ></el-input> -->
  328. {{ nickName }}
  329. </el-form-item>
  330. </el-col>
  331. <el-col :span="12">
  332. <el-form-item label="联系人:" size="normal">
  333. {{ formData.contactPerson }}
  334. </el-form-item>
  335. <el-form-item label="客户地址:" size="normal">
  336. {{ formData.customAddress }}
  337. </el-form-item>
  338. <el-form-item label="客户国别:" size="normal">
  339. {{ formData.customCountryType }}
  340. </el-form-item>
  341. </el-col>
  342. <el-col :span="12">
  343. <el-form-item label-width="120px" label="合计金额(大写):">
  344. <!-- <el-input
  345. v-model="formData.saleAmountInWords"
  346. size="small"
  347. clearable
  348. ></el-input> -->
  349. {{ formData.saleAmountInWords }}
  350. </el-form-item>
  351. </el-col>
  352. <!-- <el-col :span="12">
  353. <el-form-item label="付款方式:">
  354. <el-select
  355. v-model="formData.salePayType"
  356. size="small"
  357. clearable
  358. filterable
  359. >
  360. <el-option
  361. v-for="item in dict.type.retail_order_pay_method"
  362. :key="item.value"
  363. :label="item.label"
  364. :value="item.value"
  365. ></el-option>
  366. </el-select>
  367. 零售单
  368. </el-form-item>
  369. </el-col> -->
  370. <!-- <el-col :span="12">
  371. <el-form-item
  372. label-width="120px"
  373. prop="saleOrderEstimatedTime"
  374. label="预计下单时间:"
  375. >
  376. {{ formData.saleOrderEstimatedTime }}
  377. </el-form-item>
  378. </el-col> -->
  379. <!-- <el-col :span="12">
  380. <el-form-item label="交货日期:" size="normal" prop="deliveryDate">
  381. {{ formData.deliveryDate }}
  382. </el-form-item>
  383. </el-col> -->
  384. <!-- <el-col :span="12">
  385. <el-form-item label="交货天数:" size="normal" prop="saleLeadTime">
  386. {{ formData.saleLeadTime }}
  387. </el-form-item>
  388. </el-col> -->
  389. <el-col :span="24">
  390. <el-divider>货品明细</el-divider>
  391. </el-col>
  392. <el-table
  393. :data="productionTableData"
  394. border
  395. show-summary
  396. :summary-method="getSummaries"
  397. sum-text="小计"
  398. style="width: 100%"
  399. >
  400. <el-table-column prop="productName" label="品名" width="180">
  401. <template slot-scope="scope">
  402. <!-- <el-input
  403. v-model="scope.row.productName"
  404. size="small"
  405. clearable
  406. ></el-input> -->
  407. <el-select
  408. v-model="scope.row.productNo"
  409. placeholder=""
  410. :filter-method="(val) => mySelectFilter(val, scope.row)"
  411. clearable
  412. filterable
  413. @change="
  414. handleProductChange(scope.row.productNo, scope.row)
  415. "
  416. >
  417. <el-option
  418. v-for="item in productionOptions"
  419. :key="item.productNo"
  420. :label="item.productName"
  421. :value="item.productNo"
  422. >
  423. <span class="discribe" style="float: left">{{
  424. item.productName
  425. }}</span>
  426. <span
  427. style="float: right; color: #8492a6; font-size: 13px"
  428. >{{ item.productSpecifications }}</span
  429. >
  430. </el-option>
  431. </el-select>
  432. </template>
  433. </el-table-column>
  434. <el-table-column prop="productType" label="类型">
  435. </el-table-column>
  436. <el-table-column prop="productNumber" label="箱数">
  437. <template slot-scope="scope">
  438. <el-input
  439. v-model="scope.row.productNumber"
  440. oninput="value=value.replace(/[^0-9.]/g,'')"
  441. size="small"
  442. clearable
  443. @change="computedPrice(scope.row)"
  444. ></el-input>
  445. </template>
  446. </el-table-column>
  447. <el-table-column prop="productUnitPrice" label="单价">
  448. <template slot-scope="scope">
  449. <el-input
  450. v-model="scope.row.productUnitPrice"
  451. size="small"
  452. oninput="value=value.replace(/[^0-9.]/g,'')"
  453. @change="computedPrice(scope.row)"
  454. clearable
  455. ></el-input>
  456. </template>
  457. </el-table-column>
  458. <el-table-column prop="productAmounts" label="金额">
  459. <template slot-scope="scope">
  460. {{ scope.row.productAmounts }}
  461. </template>
  462. </el-table-column>
  463. <el-table-column prop="sliceType" label="切片型号">
  464. <template slot-scope="scope">
  465. <el-select
  466. v-model="scope.row.sliceType"
  467. placeholder=""
  468. clearable
  469. filterable
  470. @change="sliceTypeChangeHandler(scope.row)"
  471. >
  472. <el-option
  473. v-for="item in sliceTypeOptions"
  474. :key="item.materielCode"
  475. :label="item.materielName"
  476. :value="item.materielCode"
  477. >
  478. </el-option>
  479. </el-select>
  480. </template>
  481. </el-table-column>
  482. <el-table-column prop="colourNumber" label="色号">
  483. <template slot-scope="scope">
  484. <el-select
  485. v-model="scope.row.colourNumber"
  486. placeholder=""
  487. clearable
  488. filterable
  489. @change="colourNumberChangeHandler(scope.row)"
  490. >
  491. <el-option
  492. v-for="item in colourNumberOptions"
  493. :key="item.materielCode"
  494. :label="item.materieEncoding + item.materieColorNumber"
  495. :value="item.materielCode"
  496. >
  497. <span class="discribe" style="float: left">{{
  498. item.materieEncoding + item.materieColorNumber
  499. }}</span>
  500. <!-- <span
  501. style="float: right; color: #8492a6; font-size: 13px"
  502. >{{ item.materielCode }}</span
  503. > -->
  504. </el-option>
  505. </el-select>
  506. </template>
  507. </el-table-column>
  508. <el-table-column prop="remark" label="备注">
  509. <template slot-scope="scope">
  510. <el-input
  511. v-model="scope.row.remark"
  512. size="small"
  513. clearable
  514. ></el-input>
  515. </template>
  516. </el-table-column>
  517. <el-table-column label="操作">
  518. <template slot-scope="scope">
  519. <el-button
  520. type="danger"
  521. size="small"
  522. @click="deleteProduct(scope.$index)"
  523. >删除</el-button
  524. >
  525. </template>
  526. </el-table-column>
  527. </el-table>
  528. <el-button
  529. class="mt5"
  530. type="primary"
  531. style="width: 100%"
  532. size="small"
  533. @click="addProduct"
  534. >添加货品</el-button
  535. >
  536. <!-- <el-col :span="12" v-show="formData.salePayType == '1'">
  537. <el-form-item prop="earnestMoney" label="定金">
  538. <el-input
  539. v-model="formData.earnestMoney"
  540. clearable
  541. size="small"
  542. />
  543. </el-form-item>
  544. </el-col> -->
  545. <el-col :span="24">
  546. <el-divider>订单备注</el-divider>
  547. </el-col>
  548. <el-col :span="24">
  549. <el-input
  550. type="textarea"
  551. v-model="formData.orderRemark"
  552. placeholder=""
  553. size="normal"
  554. clearable
  555. ></el-input>
  556. </el-col>
  557. <!-- <el-col :span="24">
  558. <el-divider>审计人员数据</el-divider>
  559. </el-col> -->
  560. </el-form>
  561. </el-row>
  562. <div slot="footer" class="dialog-footer">
  563. <el-button type="primary" @click="editConfirm">确 定</el-button>
  564. <el-button @click="cancel">取 消</el-button>
  565. </div>
  566. </el-dialog>
  567. <!-- 自定义弹窗 -->
  568. <el-dialog title="提交" :visible.sync="deliverShow" width="1200px">
  569. <!-- <DialogTemplate
  570. ref="dialogRef"
  571. :groupKey="groupKey"
  572. :rowobj="rowobj"
  573. :subCount="subCount"
  574. :tableCount="tableCount"
  575. :subTableName="subTableName"
  576. @addList="addListHandler"
  577. >
  578. </DialogTemplate> -->
  579. <RetailProvide ref="deliverRef"></RetailProvide>
  580. <span slot="footer" class="dialog-footer">
  581. <el-button @click="deliverShow = false">取 消</el-button>
  582. <!-- <el-button @click="btnSave">保 存</el-button> -->
  583. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  584. </span>
  585. </el-dialog>
  586. <!-- 详情弹窗 -->
  587. <el-dialog title="详情" :visible.sync="detailShow" width="1250px">
  588. <div ref="detailTable" id="detail"></div>
  589. <span slot="footer" class="dialog-footer">
  590. <el-button @click="detailShow = false">取 消</el-button>
  591. <el-button type="primary" @click="detailPrintHandler"
  592. >打 印</el-button
  593. >
  594. </span>
  595. </el-dialog>
  596. <!-- 销售出库弹窗 -->
  597. <el-dialog
  598. title="打印-销售出库单"
  599. :visible.sync="outBoundShow"
  600. width="1000px"
  601. >
  602. <OutBound ref="outBoundRef" :currentRow="currentRow"></OutBound>
  603. <span slot="footer" class="dialog-footer">
  604. <el-button @click="outBoundShow = false">取 消</el-button>
  605. <el-button type="primary" @click="outBoundPrintHandler">
  606. 打印</el-button
  607. >
  608. </span>
  609. </el-dialog>
  610. <!-- 出库详情 -->
  611. <el-dialog title="出库明细" :visible.sync="outStockShow" width="1200px">
  612. <OutStock ref="outStockRef"></OutStock>
  613. <span slot="footer" class="dialog-footer">
  614. <el-button @click="outStockShow = false">关 闭</el-button>
  615. <!-- <el-button @click="btnSave">保 存</el-button> -->
  616. <!-- <el-button type="primary" @click="btnComfirm">确 定</el-button> -->
  617. </span>
  618. </el-dialog>
  619. <div id="printDom"></div>
  620. </div>
  621. </el-card>
  622. </template>
  623. <script>
  624. import {
  625. delTableData,
  626. dragTableInfo,
  627. listTable,
  628. unionListTableData,
  629. getInfoBySqlKey,
  630. btnCommonApi,
  631. addTableData,
  632. batchEdit,
  633. getStatisticList,
  634. getTableList1,
  635. checkOrderNo,
  636. delOrder,
  637. productInvoiceInfo,
  638. addProductInvoice,
  639. updateProductInvoice,
  640. queryMaterielList,
  641. } from "@/api/tablelist/commonTable";
  642. import {
  643. saleOrderList,
  644. getRoleUser,
  645. addRetailOrder,
  646. getRetailOrderInfo,
  647. editRetailOrder,
  648. retailProductInvoiceInfo,
  649. submitRetailOrder,
  650. cancelRetailOrder,
  651. } from "@/api/system/retailMange.js";
  652. import { listData } from "@/api/system/tenant/data";
  653. import { getToken } from "@/utils/auth";
  654. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  655. import { camelCase, toUnderline } from "@/utils";
  656. import { inputDisableComplete } from "@/utils/other";
  657. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  658. import { checkRole } from "@/utils/permission";
  659. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  660. import {
  661. queryDropDownBoxData,
  662. getSaleOrderProductionList,
  663. } from "@/api/dragform/form";
  664. import { v4 as uuidv4 } from "uuid";
  665. import { mapState } from "vuex";
  666. import moment from "moment";
  667. import Deliver from "@/views/orderMange/components/dialogForm/Deliver.vue";
  668. import RetailProvide from "@/views/orderMange/components/dialogForm/RetailProvide.vue";
  669. import OutStock from "@/views/orderMange/components/dialogForm/OutStock.vue";
  670. import OutBound from "@/views/orderMange/components/dialogForm/OutBound.vue";
  671. import outBoundPrint from "@/utils/print/outBoundPrint";
  672. import { listCustomer } from "@/api/system/customer";
  673. import { numToCapital } from "@/utils/other";
  674. export default {
  675. name: "retailMange",
  676. dicts: [
  677. "payment_method",
  678. "direction_of_twist",
  679. "retail_order_pay_method",
  680. "sales_order_status",
  681. ],
  682. components: {
  683. Queryfrom,
  684. Menu,
  685. DialogTemplate,
  686. Deliver,
  687. OutBound,
  688. RetailProvide,
  689. OutStock,
  690. },
  691. data() {
  692. return {
  693. outStockShow: false, //出库详情弹窗
  694. totalMoney: "", //合计金额 小写
  695. createById: "", //创建者id
  696. salesmanList: [], //销售员列表
  697. isLeader: false, //当前登录用户是否为领导
  698. selection: [], //勾选的数据
  699. // 出库单 start
  700. outBoundShow: false,
  701. // 出库单 end
  702. // 发货 start
  703. deliverShow: false,
  704. // 发货 end
  705. // 出库单 start
  706. // 出库单 end
  707. myDelIds: [], //新增接口 删除的id
  708. // 详情弹窗数据
  709. detailShow: false,
  710. printDomData: "",
  711. // k-form-build组件渲染弹窗
  712. kOpen: false,
  713. // 新的自定义数据 start
  714. orderType: 0, //新的条件查询参数
  715. productIds: [], //货品Ids
  716. isEdit: false,
  717. formData: {
  718. //订单表数据
  719. saleNo: "", //合同号
  720. saleCustomNo: "", //客户编号
  721. saleDate: "", //销售单日期
  722. saleOrderEstimatedTime: "", //预计下单时间
  723. saleLeadTime: "1", //交货周期
  724. deliveryDate: "", //交货日期
  725. saleAmounts: "", //合计金额 小写
  726. saleAmountInWords: "", //合计金额 大写
  727. salePayType: "1", //支付方式
  728. earnestMoney: "", //定金
  729. salesman: "", //业务员
  730. saleLeader: "", //业务主管
  731. finance: "", //财务部
  732. production: "", //生产部
  733. saleApprover: "", //批准人
  734. customAddress: "", //客户地址
  735. customCountryType: "", //国家类型
  736. contactPerson: "", //联系人
  737. // 货品明细表数据
  738. lotNumber: "", //批号
  739. productNo: "", //货品号
  740. productName: "", //货品名称
  741. productNumber: "", //销售数量
  742. productWeight: "", //销售重量kg
  743. productUnitPrice: "", //单价
  744. productAmounts: "", //金额
  745. sliceType: "", //切片类型
  746. sliceTypeLabel: "",
  747. colourNumberLabel: "",
  748. colourNumber: "", //色号
  749. remark: "", //备注
  750. // 工艺表
  751. orderRemark: "",
  752. },
  753. sliceTypeOptions: [], //切片型号选项
  754. colourNumberOptions: [], //色号选项
  755. allProductionOptions: [], //所有产品选项
  756. productionOptions: [],
  757. customerOptions: [],
  758. productionTableData: [
  759. // {
  760. // productNo: "", //货品名称
  761. // productNumber: 2, //销售数量
  762. // productWeight: 1, //销售重量kg
  763. // productUnitPrice: 20, //单价
  764. // productAmounts: 20, //金额
  765. // remark: "", //备注
  766. // },
  767. ],
  768. rules: {
  769. saleNo: [
  770. {
  771. required: true,
  772. message: "请输入合同号",
  773. trigger: "blur",
  774. },
  775. // {
  776. // validator: this.validateOrderNo,
  777. // trigger: "blur",
  778. // },
  779. ],
  780. saleDate: [
  781. {
  782. required: true,
  783. message: "请选择日期",
  784. trigger: "change",
  785. },
  786. ],
  787. // lotNumber: [
  788. // {
  789. // required: true,
  790. // message: "请输入批号",
  791. // trigger: "blur",
  792. // },
  793. // ],
  794. saleCustomNo: [
  795. {
  796. required: true,
  797. message: "请选择客户",
  798. trigger: "change",
  799. },
  800. ],
  801. saleOrderEstimatedTime: [
  802. {
  803. required: true,
  804. message: "请选择预计下单时间",
  805. trigger: "change",
  806. },
  807. ],
  808. saleLeadTime: [
  809. {
  810. required: true,
  811. message: "请输入交货天数",
  812. trigger: "blur",
  813. },
  814. ],
  815. // earnestMoney: [
  816. // {
  817. // validator: this.validateEarnestMoney,
  818. // trigger: "blur",
  819. // },
  820. // ],
  821. },
  822. // end
  823. // 绑定按钮dialog
  824. btnDialogVisible: false,
  825. // 绑定修改dialog
  826. groupKey: "",
  827. // 遮罩层
  828. loading: true,
  829. // 选中数组
  830. ids: [],
  831. // 非单个禁用
  832. single: true,
  833. // 非多个禁用
  834. multiple: true,
  835. // 显示统计
  836. showCount: true,
  837. // 显示搜索条件
  838. showSearch: true,
  839. // 总条数
  840. total: 0,
  841. // 用户表格数据
  842. tableList: [],
  843. // 弹出层标题
  844. title: "",
  845. // 日期范围
  846. dateRange: [],
  847. // 表单参数
  848. form: {},
  849. // cru 弹窗
  850. open: false,
  851. // excel共通导入数据
  852. upload: {
  853. // 是否显示弹出层
  854. open: false,
  855. // 弹出层标题(
  856. title: "",
  857. // 是否禁用上传
  858. isUploading: false,
  859. // 是否更新已经存在的数据
  860. updateSupport: 0,
  861. // 设置上传的请求头部
  862. headers: { Authorization: "Bearer " + getToken() },
  863. // 上传的地址
  864. url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
  865. },
  866. // 排序方式 默认降序
  867. sortOrder: true,
  868. // 共通查询参数接受子组件的参数
  869. queryParams: {
  870. saleOrderTechnologyNo: "retailOrder",
  871. pageNum: 1, // 第几页
  872. pageSize: 10, // 每页大小
  873. orderByColumn: "", // 根据某列排序
  874. isAsc: "", // desc(降序)或 asc(升序)
  875. saleOrderOrderType: "",
  876. // 基本查询参数
  877. basicMap: {
  878. tableName: "drag_form",
  879. },
  880. // 当前表字段筛选参数
  881. queryMap: {
  882. queryCriteriaValue: "",
  883. },
  884. },
  885. // 列信息
  886. columns: {},
  887. // 当前模版信息
  888. templateInfo: {},
  889. // 查询条件
  890. queryFromWhere: {},
  891. // 当前table唯一标识
  892. tableKey: null,
  893. // 当前表名称
  894. tableName: null,
  895. //存放html代码块
  896. iframeUrl: "",
  897. //存放表单渲染数据
  898. jsonData: {},
  899. // 回显表格数据,
  900. defaultValue: {},
  901. // 统计card
  902. statisticList: [],
  903. // 样式表
  904. styleList: [],
  905. // 字典样式对象
  906. dictStyleObj: {},
  907. // 操作列 按钮数据
  908. excuteBtnArr: [],
  909. // 下拉框动态数据
  910. dynamicData: {},
  911. // 当前点击按钮的数据
  912. currentBtnData: {},
  913. // 修改选中行
  914. rowobj: {},
  915. // 该行的统计信息
  916. subCount: [],
  917. tableCount: [],
  918. // 弹窗新增数据
  919. addLists: [],
  920. subTableName: "",
  921. // 当前点击行的数据
  922. currentRow: {},
  923. };
  924. },
  925. created() {
  926. // 得到当前展示的table的唯一标识
  927. this.tableKey = this.$route.query.tableKey;
  928. },
  929. watch: {
  930. totalMoney: {
  931. handler(newVal, oldVal) {
  932. if (isNaN(Number(newVal))) {
  933. this.formData.saleAmountInWords = "零";
  934. } else {
  935. const ntc = new numToCapital();
  936. this.formData.saleAmountInWords = ntc.uppercase(newVal);
  937. }
  938. },
  939. deep: true,
  940. immediate: true,
  941. },
  942. },
  943. async mounted() {
  944. await this.getDropDownData();
  945. },
  946. computed: {
  947. isShowExcuteCol() {
  948. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  949. },
  950. ...mapState({
  951. nickName: (state) => state.user.nickName,
  952. userInfo: (state) => state.user,
  953. }),
  954. },
  955. methods: {
  956. // 出库单回调
  957. async myPrintOutBoundHandler(row) {
  958. console.log("row", row);
  959. this.currentRow = row;
  960. this.outBoundShow = true;
  961. this.$nextTick(() => {
  962. this.$refs.outBoundRef.getTableData(row);
  963. });
  964. },
  965. // 出库详情回调
  966. handleOutDetail(row) {
  967. this.outStockShow = true;
  968. this.$nextTick(() => {
  969. this.$refs.outStockRef.getOutStockDetail(row);
  970. });
  971. },
  972. // 业务员改变回调
  973. salemanChange(val) {
  974. if (!val) {
  975. this.createById = "";
  976. return;
  977. } else {
  978. this.createById = this.salesmanList.find(
  979. (item) => item.value == val
  980. ).id;
  981. }
  982. },
  983. // 生成合同号
  984. getSaleNo() {
  985. let timeStr = moment().format("YYYYMMDD");
  986. for (var i = 0; i < 5; i++) {
  987. timeStr += parseInt(Math.random() * 10);
  988. }
  989. return timeStr;
  990. },
  991. // 自定义筛选方法
  992. mySelectFilter(value, row) {
  993. console.log(value);
  994. // row.productNo = value;
  995. if (value) {
  996. let target = this.productionOptions.find((item) =>
  997. item.productName.includes(value)
  998. );
  999. console.log(target);
  1000. if (target) {
  1001. this.productionOptions = [target];
  1002. //找到
  1003. return true;
  1004. } else {
  1005. //前100个没找到
  1006. // 在全部列表中查找
  1007. target = this.allProductionOptions.find((item) =>
  1008. item.productName.includes(value)
  1009. );
  1010. console.log(target);
  1011. if (target) {
  1012. this.productionOptions = [target];
  1013. return true;
  1014. } else {
  1015. return false;
  1016. }
  1017. }
  1018. } else {
  1019. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1020. }
  1021. },
  1022. // 出库单回调
  1023. async myPrintOutBoundHandler(row, data) {
  1024. console.log("row", row);
  1025. this.currentRow = row;
  1026. this.outBoundShow = true;
  1027. this.$nextTick(() => {
  1028. this.$refs.outBoundRef.getTableData(row);
  1029. });
  1030. },
  1031. // 出库单打印回调
  1032. async outBoundPrintHandler() {
  1033. let res = await this.$refs.outBoundRef.getPrintData();
  1034. console.log(res);
  1035. if (res.flag) {
  1036. res.data.form.printUser = this.nickName;
  1037. outBoundPrint(res.data, "printDom", true);
  1038. }
  1039. },
  1040. // 产品名称改变
  1041. handleProductChange(productNo, row) {
  1042. if (!productNo) {
  1043. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1044. return;
  1045. }
  1046. row.productName = this.productionOptions.find(
  1047. (item) => item.productNo == productNo
  1048. )?.productName;
  1049. row.productType = this.productionOptions.find(
  1050. (item) => item.productNo == productNo
  1051. )?.productType;
  1052. this.productionOptions = this.allProductionOptions.slice(0, 500);
  1053. },
  1054. // 订单类型改变回调
  1055. orderTypeChange(type) {
  1056. this.getList(false, type);
  1057. },
  1058. // 重置审计表单数据
  1059. resetFormData() {
  1060. Object.assign(this.formData, {
  1061. //订单表数据
  1062. saleNo: this.getSaleNo(), //合同号
  1063. saleCustomNo: "", //客户编号
  1064. saleDate: moment(new Date()).format("YYYY-MM-DD"), //销售单日期
  1065. saleOrderEstimatedTime: moment(new Date()).format("YYYY-MM-DD"), //预计下单时间
  1066. saleLeadTime: "1", //交货周期
  1067. deliveryDate: moment(new Date()).format("YYYY-MM-DD"),
  1068. saleAmounts: "", //合计金额 小写
  1069. saleAmountInWords: "", //合计金额 大写
  1070. salePayType: "1", //支付方式
  1071. earnestMoney: "",
  1072. salesman: "", //业务员
  1073. saleLeader: "", //业务主管
  1074. finance: "", //财务部
  1075. production: "", //生产部
  1076. saleApprover: "", //批准人
  1077. customAddress: "", //客户地址
  1078. customCountryType: "", //国家类型
  1079. contactPerson: "", //联系人
  1080. // 货品明细表数据
  1081. lotNumber: "", //批号
  1082. productNo: "", //货品号
  1083. productName: "", //货品名称
  1084. productNumber: "", //销售数量
  1085. productWeight: "", //销售重量kg
  1086. productUnitPrice: "", //单价
  1087. productAmounts: "", //金额
  1088. sliceType: "", //切片类型
  1089. sliceTypeLabel: "",
  1090. colourNumberLabel: "",
  1091. colourNumber: "", //色号
  1092. remark: "", //备注
  1093. // 工艺表
  1094. craftGrid: "", //网络
  1095. craftOil: "", //油剂
  1096. craftPackage: "", //卷装
  1097. craftColorFastness: "", //色牢度
  1098. directionOfTwist: "",
  1099. craftOther: "", //其它工艺要求
  1100. craftMark: "", //包装/贴唛
  1101. shippingMethod: "", //运输方式
  1102. });
  1103. this.productionTableData = [];
  1104. },
  1105. // 自定义的小计计算方法
  1106. getSummaries(param) {
  1107. const { columns, data } = param;
  1108. console.log(columns, data);
  1109. const sums = [];
  1110. columns.forEach((column, index) => {
  1111. if (index === 0) {
  1112. sums[index] = "小计";
  1113. return;
  1114. }
  1115. const values = data.map((item) => Number(item[column.property]));
  1116. if (
  1117. index === 1 ||
  1118. index === 5 ||
  1119. index === 6 ||
  1120. index === 7 ||
  1121. index === 8
  1122. ) {
  1123. sums[index] = "";
  1124. } else if (!values.every((value) => isNaN(value))) {
  1125. sums[index] = values
  1126. .reduce((prev, curr) => {
  1127. const value = Number(curr);
  1128. if (!isNaN(value)) {
  1129. return prev + curr;
  1130. } else {
  1131. return prev;
  1132. }
  1133. }, 0)
  1134. ?.toFixed(2);
  1135. console.log(sums[index], index);
  1136. if (index == 4) {
  1137. this.totalMoney = sums[index];
  1138. }
  1139. } else {
  1140. sums[index] = "N/A";
  1141. }
  1142. });
  1143. return sums;
  1144. },
  1145. // 货品表格数据删除回调
  1146. deleteProduct(index) {
  1147. this.productionTableData.splice(index, 1);
  1148. },
  1149. // 货品表格数据新增回调
  1150. addProduct() {
  1151. this.productionTableData.push({
  1152. saleProductNo: uuidv4(),
  1153. productNo: "", //货品编号
  1154. productType: "", //类型
  1155. productName: "", //货品名称
  1156. productNumber: "", //销售数量
  1157. productWeight: "", //销售重量kg
  1158. productUnitPrice: "", //单价
  1159. productAmounts: "", //金额
  1160. sliceType: "022", //切片类型 初始为 切片
  1161. sliceTypeLabel: "",
  1162. colourNumberLabel: "",
  1163. colourNumber: "", //色号
  1164. remark: "", //备注
  1165. });
  1166. },
  1167. // 客户名称改变回调
  1168. customChangeHandler(val) {
  1169. // if (!val) return;
  1170. let customData = this.customerOptions.find(
  1171. (item) => item.customNo == val
  1172. );
  1173. this.formData.customAddress = customData?.customAddress || "无";
  1174. this.formData.customCountryType = customData?.customCountryType || "无";
  1175. this.formData.contactPerson = customData?.contactPerson || "无";
  1176. },
  1177. // 获取销售员角色列表
  1178. async getRoleUser() {
  1179. try {
  1180. let res = await getRoleUser("salesman");
  1181. if (res.code == 200) {
  1182. this.salesmanList = res.data.map((item) => {
  1183. return {
  1184. label: item.nickName,
  1185. value: item.nickName,
  1186. id: item.userId,
  1187. };
  1188. });
  1189. } else {
  1190. this.$message.error("获取销售员角色列表失败");
  1191. }
  1192. } catch (error) {
  1193. console.log(error);
  1194. }
  1195. },
  1196. //审计新增
  1197. async addHandler() {
  1198. this.isEdit = false;
  1199. await this.getDropDownData();
  1200. // 判断是否是销售员
  1201. console.log(this.userInfo);
  1202. this.isLeader = !this.userInfo.roles.includes("salesman");
  1203. if (!this.isLeader) {
  1204. this.createById = this.userInfo.userId;
  1205. }
  1206. await this.getRoleUser();
  1207. this.resetFormData();
  1208. this.title = "新增零售单";
  1209. this.open = true;
  1210. this.$nextTick(() => {
  1211. this.$refs.formDataRef.resetFields();
  1212. this.formData.orderRemark = "";
  1213. // this.$refs["formDataRef"].clearValidate();
  1214. });
  1215. },
  1216. // 获取下拉框数据
  1217. async getDropDownData() {
  1218. try {
  1219. // let payLoad = [
  1220. // {
  1221. // basicMap: {
  1222. // tableName: "production",
  1223. // },
  1224. // },
  1225. // {
  1226. // basicMap: {
  1227. // tableName: "customer",
  1228. // },
  1229. // },
  1230. // ];
  1231. // let res = await queryDropDownBoxData(payLoad);
  1232. // 新的获取客户选项数据的接口
  1233. let res = await listCustomer({ isEnablePaging: false });
  1234. if (res.code == 200) {
  1235. // let { customer } = res.data.resultMap;
  1236. // this.allProductionOptions = production || [];
  1237. // this.productionOptions =
  1238. // this.allProductionOptions.slice(0, 100) || [];
  1239. this.customerOptions = res.rows || [];
  1240. } else {
  1241. throw Error("获取下拉框数据失败");
  1242. }
  1243. let proRes = await getSaleOrderProductionList();
  1244. if (proRes.code == 200) {
  1245. // let { production, customer } = proRes.data.resultMap;
  1246. this.allProductionOptions = proRes.data || [];
  1247. this.productionOptions =
  1248. this.allProductionOptions.slice(0, 500) || [];
  1249. } else {
  1250. throw Error("获取下拉框数据失败");
  1251. }
  1252. } catch (error) {
  1253. console.log(error);
  1254. }
  1255. // 色号数据
  1256. try {
  1257. let payLoad = [
  1258. {
  1259. basicMap: {
  1260. tableName: "materiel",
  1261. },
  1262. conditionMap: {
  1263. materiel_species: ["1"],
  1264. },
  1265. },
  1266. ];
  1267. // let res = await queryDropDownBoxData(payLoad);
  1268. let res = await queryMaterielList();
  1269. if (res.code == 200) {
  1270. // let { materiel } = res.data;
  1271. this.colourNumberOptions = res.data || [];
  1272. } else {
  1273. throw Error("获取下拉框数据失败");
  1274. }
  1275. } catch (error) {
  1276. console.log(error);
  1277. }
  1278. // 切片型号
  1279. try {
  1280. let payLoad = [
  1281. {
  1282. basicMap: {
  1283. tableName: "materiel",
  1284. },
  1285. conditionMap: {
  1286. materiel_species: ["6"],
  1287. },
  1288. },
  1289. ];
  1290. let res = await queryDropDownBoxData(payLoad);
  1291. if (res.code == 200) {
  1292. console.log(res.data.resultMap);
  1293. let { materiel } = res.data.resultMap;
  1294. this.sliceTypeOptions = materiel || [];
  1295. } else {
  1296. throw Error("获取下拉框数据失败");
  1297. }
  1298. } catch (error) {
  1299. console.log(error);
  1300. }
  1301. },
  1302. //
  1303. // 获取row-key
  1304. getRowKey(row) {
  1305. return row[
  1306. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1307. ];
  1308. },
  1309. /** 查询列表 */
  1310. async getList() {
  1311. this.loading = true;
  1312. try {
  1313. let res = await saleOrderList(this.queryParams);
  1314. console.log(res);
  1315. if (res.code == 200) {
  1316. this.tableList = res.rows;
  1317. console.log(this.dict.type.sales_order_status);
  1318. this.tableList.forEach((item) => {
  1319. item.listClass = this.dict.type.sales_order_status.find(
  1320. (i) => i.value == item.status
  1321. ).raw.listClass;
  1322. });
  1323. this.total = res.total;
  1324. } else {
  1325. this.$message.error(res.msg);
  1326. }
  1327. this.loading = false;
  1328. } catch (error) {
  1329. console.log(error);
  1330. this.loading = false;
  1331. }
  1332. },
  1333. // 校验定金
  1334. validateEarnestMoney(rule, value, callback) {
  1335. console.log(value);
  1336. if (this.formData.salePayType == "1") {
  1337. if (value == "" || value == null || value == undefined) {
  1338. callback(new Error("请输入定金金额"));
  1339. } else {
  1340. callback();
  1341. }
  1342. } else {
  1343. callback();
  1344. }
  1345. },
  1346. // 校验订单号是否有效
  1347. async validateOrderNo(rule, value, callback) {
  1348. console.log(value);
  1349. // let saleNo = this.formData.orderNo;
  1350. // 检验订单号合法
  1351. let checkNoPayload = {
  1352. saleNo: value,
  1353. };
  1354. if (this.isEdit) {
  1355. checkNoPayload.id = this.formData.id;
  1356. }
  1357. let result = await checkOrderNo(checkNoPayload);
  1358. if (result.code == 200) {
  1359. if (result.data) {
  1360. callback();
  1361. } else {
  1362. callback(new Error("合同号已存在"));
  1363. }
  1364. } else {
  1365. callback(new Error("校验失败,请稍后再试"));
  1366. }
  1367. },
  1368. // 校验表格数据
  1369. validateTableData() {
  1370. if (this.productionTableData.length == 0) {
  1371. return {
  1372. res: false,
  1373. msg: "请添加货品明细",
  1374. };
  1375. }
  1376. let res = this.productionTableData.every((item) => {
  1377. return (
  1378. item.productNo &&
  1379. item.productNumber &&
  1380. item.productUnitPrice &&
  1381. item.productAmounts &&
  1382. item.sliceType &&
  1383. item.colourNumber
  1384. );
  1385. });
  1386. if (!res) {
  1387. return {
  1388. res: false,
  1389. msg: "请填写完整货品明细",
  1390. };
  1391. }
  1392. return {
  1393. res: true,
  1394. msg: "",
  1395. };
  1396. },
  1397. // 审计 提交编辑结果按钮回调
  1398. async editConfirm() {
  1399. this.$refs.formDataRef.validate(async (valid) => {
  1400. if (valid) {
  1401. console.log(valid);
  1402. let tableValidate = this.validateTableData();
  1403. if (!tableValidate.res) {
  1404. this.$message.warning(tableValidate.msg);
  1405. return;
  1406. }
  1407. let {
  1408. id,
  1409. //订单表数据
  1410. saleNo,
  1411. saleCustomNo,
  1412. saleDate,
  1413. saleOrderEstimatedTime,
  1414. saleLeadTime,
  1415. deliveryDate,
  1416. saleAmounts,
  1417. saleAmountInWords,
  1418. salePayType,
  1419. salesman,
  1420. customAddress,
  1421. customCountryType, //国家类型
  1422. contactPerson, //联系人
  1423. // 工艺表数据
  1424. orderRemark,
  1425. } = this.formData;
  1426. let payload = {
  1427. createById: this.createById,
  1428. saleOrderTechnologyNo: "retailOrder",
  1429. saleNo,
  1430. saleCustomNo,
  1431. saleDate,
  1432. saleOrderEstimatedTime,
  1433. saleLeadTime,
  1434. deliveryDate,
  1435. saleAmounts,
  1436. saleAmountInWords,
  1437. salePayType,
  1438. customAddress, //客户地址
  1439. customCountryType, //国家类型
  1440. contactPerson, //联系人
  1441. remark: orderRemark,
  1442. salesman: this.isLeader ? salesman : this.nickName,
  1443. status: 1,
  1444. };
  1445. payload.saleProductsList = this.productionTableData;
  1446. if (this.isEdit) {
  1447. payload.id = id;
  1448. let res = await editRetailOrder(payload);
  1449. if (res.code === 200) {
  1450. this.$message.success("修改成功");
  1451. this.open = false;
  1452. this.getList();
  1453. } else {
  1454. this.$message.error("修改失败");
  1455. }
  1456. } else {
  1457. //新增
  1458. let res = await addRetailOrder(payload);
  1459. if (res.code == 200) {
  1460. this.$message.success("添加成功");
  1461. this.open = false;
  1462. this.getList();
  1463. } else {
  1464. this.$message.error("添加失败");
  1465. }
  1466. }
  1467. // Object.keys(saleValue).map((k) => {
  1468. // saleData.commMap[k] = saleValue[k];
  1469. // });
  1470. }
  1471. });
  1472. },
  1473. // 审计 编辑回调
  1474. async handleEdit(index, row) {
  1475. console.log(row);
  1476. let { saleOrderSaleNo } = row;
  1477. try {
  1478. let payLoad = [
  1479. {
  1480. basicMap: {
  1481. tableName: "sale_order",
  1482. },
  1483. conditionMap: {
  1484. sale_no: [saleOrderSaleNo],
  1485. },
  1486. },
  1487. {
  1488. basicMap: {
  1489. tableName: "sale_products",
  1490. },
  1491. conditionMap: {
  1492. sale_order_no: [saleOrderSaleNo],
  1493. },
  1494. },
  1495. {
  1496. basicMap: {
  1497. tableName: "sale_craft",
  1498. },
  1499. conditionMap: {
  1500. sale_order_no: [saleOrderSaleNo],
  1501. },
  1502. },
  1503. ];
  1504. let res = await queryDropDownBoxData(payLoad);
  1505. if (res.code == 200) {
  1506. this.isEdit = true;
  1507. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1508. Object.assign(this.formData, {
  1509. ...sale_craft[0],
  1510. ...sale_order[0],
  1511. });
  1512. let { saleDate, saleOrderEstimatedTime, deliveryDate } =
  1513. sale_order[0];
  1514. saleDate && (this.formData.saleDate = new Date(saleDate));
  1515. saleOrderEstimatedTime &&
  1516. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1517. deliveryDate && (this.formData.deliveryDate = new Date(deliveryDate));
  1518. this.productIds = sale_products.map((item) => item.saleProductNo);
  1519. await this.getDropDownData();
  1520. this.productionTableData = sale_products.map((item) => {
  1521. item.productType = this.productionOptions.find(
  1522. (i) => item.productNo == i.productNo
  1523. )?.productType;
  1524. return item;
  1525. });
  1526. if (this.formData.saleCustomNo) {
  1527. this.customChangeHandler(this.formData.saleCustomNo);
  1528. }
  1529. this.title = "编辑审计单";
  1530. this.open = true;
  1531. }
  1532. } catch (error) {
  1533. console.log(error);
  1534. }
  1535. },
  1536. // 审计 批量删除回调
  1537. async batchDelete() {
  1538. if (!this.ids.length) return;
  1539. try {
  1540. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1541. confirmButtonText: "确定",
  1542. cancelButtonText: "取消",
  1543. type: "warning",
  1544. });
  1545. let orderPayload = {
  1546. basicMap: {
  1547. tableName: "sale_order",
  1548. },
  1549. conditionMap: {
  1550. saleNo: this.ids,
  1551. },
  1552. };
  1553. let productsPayload = {
  1554. basicMap: {
  1555. tableName: "sale_products",
  1556. },
  1557. conditionMap: {
  1558. saleOrderNo: this.ids,
  1559. },
  1560. };
  1561. let craftPayload = {
  1562. basicMap: {
  1563. tableName: "sale_craft",
  1564. },
  1565. conditionMap: {
  1566. saleOrderNo: this.ids,
  1567. },
  1568. };
  1569. let orderRes = await delTableData(orderPayload);
  1570. // let productRes = await delTableData(productsPayload);
  1571. // let craftRes = await delTableData(craftPayload);
  1572. if (orderRes.code == 200) {
  1573. this.$message.success("删除成功");
  1574. this.getList();
  1575. } else {
  1576. this.$message.error("删除失败");
  1577. throw Error("删除失败");
  1578. }
  1579. this.ids = [];
  1580. this.$refs.tableRef.clearSelection();
  1581. } catch (error) {
  1582. console.log(error);
  1583. }
  1584. },
  1585. // 计算金额
  1586. computedPrice(row) {
  1587. let { productNumber, productUnitPrice } = row;
  1588. console.log(
  1589. "productNumber, productUnitPrice",
  1590. productNumber,
  1591. productUnitPrice
  1592. );
  1593. row.productAmounts = (
  1594. Number(productNumber) * Number(productUnitPrice)
  1595. ).toFixed(2);
  1596. },
  1597. isUpperCase(char) {
  1598. return char === char.toUpperCase();
  1599. },
  1600. // 下划线命名转驼峰命名
  1601. toUnderScoreCase(str) {
  1602. if (str === null) {
  1603. return null;
  1604. }
  1605. let sb = "";
  1606. // 前置字符是否大写
  1607. let preCharIsUpperCase = true;
  1608. // 当前字符是否大写
  1609. let curreCharIsUpperCase = true;
  1610. // 下一字符是否大写
  1611. let nexteCharIsUpperCase = true;
  1612. for (let i = 0; i < str.length; i++) {
  1613. let c = str.charAt(i);
  1614. if (i > 0) {
  1615. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1616. } else {
  1617. preCharIsUpperCase = false;
  1618. }
  1619. curreCharIsUpperCase = isUpperCase(c);
  1620. if (i < str.length - 1) {
  1621. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1622. }
  1623. if (
  1624. preCharIsUpperCase &&
  1625. curreCharIsUpperCase &&
  1626. !nexteCharIsUpperCase
  1627. ) {
  1628. sb += SEPARATOR;
  1629. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1630. sb += SEPARATOR;
  1631. }
  1632. sb += c.toLowerCase();
  1633. }
  1634. return sb;
  1635. },
  1636. // 处理列表信息
  1637. columnsHandler(columns) {
  1638. let resArr = [];
  1639. console.log(columns, 111);
  1640. columns.forEach((item) => {
  1641. for (const key in item) {
  1642. let tempObj = {};
  1643. tempObj.key = camelCase(key);
  1644. tempObj.value = item[key];
  1645. resArr.push(tempObj);
  1646. }
  1647. });
  1648. console.log(resArr, 222);
  1649. return resArr;
  1650. },
  1651. // 取消按钮
  1652. cancel() {
  1653. this.open = false;
  1654. // this.reset();
  1655. },
  1656. // k-form-build 取消按钮
  1657. kCancel() {
  1658. this.kOpen = false;
  1659. // this.reset();
  1660. },
  1661. // 分页查询
  1662. pageList(row) {
  1663. // 调用子组件-》携带子组件参数请求后台
  1664. this.$refs.mychild.pageList(
  1665. row == undefined
  1666. ? {
  1667. limit: this.queryParams.pageSize,
  1668. page: this.queryParams.pageNum,
  1669. }
  1670. : row
  1671. );
  1672. },
  1673. // 多选框选中数据
  1674. handleSelectionChange(selection) {
  1675. // this.ids = selection.map(
  1676. // (item) =>
  1677. // item[
  1678. // camelCase(
  1679. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1680. // )
  1681. // ]
  1682. // );
  1683. this.selection = selection;
  1684. this.myDelIds = selection.map((item) => item.saleOrderId);
  1685. console.log(this.myDelIds);
  1686. this.ids = selection.map((item) => item.saleOrderSaleNo);
  1687. this.single = selection.length != 1;
  1688. this.multiple = !selection.length;
  1689. },
  1690. // 更多操作触发
  1691. handleCommand(command, row) {
  1692. switch (command) {
  1693. case "handleResetPwd":
  1694. this.handleResetPwd(row);
  1695. break;
  1696. case "handleAuthRole":
  1697. this.handleAuthRole(row);
  1698. break;
  1699. default:
  1700. break;
  1701. }
  1702. },
  1703. /** 新增按钮操作 */
  1704. handleAdd(row) {
  1705. // this.reset();
  1706. this.defaultValue = {};
  1707. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1708. if (!data || !data.dfVueTemplate) {
  1709. this.jsonData = false;
  1710. this.$message.error("当前表格未绑定表单!");
  1711. return;
  1712. }
  1713. if (data.dfFormSql) {
  1714. let dynamicData = JSON.parse(data.dfFormSql);
  1715. Object.assign(this.dynamicData, dynamicData);
  1716. }
  1717. this.jsonData = JSON.parse(data.dfVueTemplate);
  1718. this.open = true;
  1719. this.title = "添加信息";
  1720. this.form.password = this.initPassword;
  1721. this.$nextTick(() => {
  1722. this.$refs.addFromRef.reset();
  1723. inputDisableComplete();
  1724. });
  1725. });
  1726. },
  1727. longestCommonSubstring(strs) {
  1728. if (!strs || strs.includes("")) return "";
  1729. let str1_Length = strs[0].length;
  1730. let str_Nums = strs.length;
  1731. let flag = 0;
  1732. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1733. let char = strs[0][i];
  1734. for (var j = 1; j < str_Nums; j++) {
  1735. if (char !== strs[j][i] || i == strs[j].length) {
  1736. return strs[1].substring(0, i);
  1737. }
  1738. }
  1739. }
  1740. return strs[0];
  1741. },
  1742. // 绑定dialog对话框关闭
  1743. handleClose() {
  1744. this.btnDialogVisible = false;
  1745. },
  1746. getLastUppercaseWord(text) {
  1747. const pattern = /\b[A-Z][a-z]*\b/g;
  1748. const matches = [...text.matchAll(pattern)];
  1749. if (matches.length > 0) {
  1750. const lastMatch = matches[matches.length - 1][0];
  1751. return lastMatch;
  1752. } else {
  1753. return null;
  1754. }
  1755. },
  1756. // 初始化数据
  1757. initData(data) {
  1758. let {
  1759. id,
  1760. //订单表数据
  1761. saleNo,
  1762. saleCustomNo,
  1763. saleDate,
  1764. saleOrderEstimatedTime,
  1765. saleLeadTime,
  1766. deliveryDate,
  1767. saleAmounts,
  1768. saleAmountInWords,
  1769. salePayType,
  1770. salesman,
  1771. customAddress,
  1772. customCountryType, //国家类型
  1773. contactPerson, //联系人
  1774. // 工艺表数据
  1775. remark,
  1776. // 产品列表
  1777. saleProductsList,
  1778. } = data;
  1779. Object.assign(this.formData, {
  1780. id,
  1781. //订单表数据
  1782. saleNo,
  1783. saleCustomNo,
  1784. saleDate,
  1785. saleOrderEstimatedTime,
  1786. saleLeadTime,
  1787. deliveryDate,
  1788. saleAmounts,
  1789. saleAmountInWords,
  1790. salePayType,
  1791. salesman,
  1792. customAddress,
  1793. customCountryType, //国家类型
  1794. contactPerson, //联系人
  1795. // 工艺表数据
  1796. orderRemark: remark,
  1797. });
  1798. this.customChangeHandler(saleCustomNo);
  1799. this.productionTableData = saleProductsList.map((item) => {
  1800. let {
  1801. id,
  1802. saleProductNo,
  1803. productNo, //货品编号
  1804. productName, //货品名称
  1805. productNumber, //销售数量
  1806. productWeight, //销售重量kg
  1807. productUnitPrice, //单价
  1808. productAmounts, //金额
  1809. sliceType, //切片类型 初始为 切片
  1810. sliceTypeLabel,
  1811. colourNumberLabel,
  1812. colourNumber, //色号
  1813. remark, //备注
  1814. } = item;
  1815. let productType = this.allProductionOptions.find(
  1816. (i) => productNo == i.productNo
  1817. )?.productType;
  1818. return {
  1819. id,
  1820. saleProductNo,
  1821. productNo, //货品编号
  1822. productType, //类型
  1823. productName, //货品名称
  1824. productNumber, //销售数量
  1825. productWeight, //销售重量kg
  1826. productUnitPrice, //单价
  1827. productAmounts, //金额
  1828. sliceType, //切片类型 初始为 切片
  1829. sliceTypeLabel,
  1830. colourNumberLabel,
  1831. colourNumber, //色号
  1832. remark,
  1833. };
  1834. });
  1835. },
  1836. /** 修改按钮操作 */
  1837. async handleUpdate(row) {
  1838. console.log(row);
  1839. this.isEdit = true;
  1840. await this.getDropDownData();
  1841. this.isLeader = !this.userInfo.roles.includes("salesman");
  1842. if (!this.isLeader) {
  1843. this.createById = this.userInfo.userId;
  1844. }
  1845. await this.getRoleUser();
  1846. this.title = "修改零售单";
  1847. try {
  1848. let res = await getRetailOrderInfo(row.id);
  1849. console.log(res);
  1850. if (res.code == 200) {
  1851. this.initData(res.data);
  1852. this.open = true;
  1853. } else {
  1854. this.$message.error(res.msg);
  1855. }
  1856. } catch (error) {
  1857. console.log(error);
  1858. }
  1859. },
  1860. //详情 打印回调
  1861. async handlePrint(row) {
  1862. await this.getDropDownData();
  1863. this.isLeader = !this.userInfo.roles.includes("salesman");
  1864. if (!this.isLeader) {
  1865. this.createById = this.userInfo.userId;
  1866. }
  1867. await this.getRoleUser();
  1868. try {
  1869. let res = await getRetailOrderInfo(row.id);
  1870. console.log(res);
  1871. if (res.code == 200) {
  1872. this.initData(res.data);
  1873. this.printDomData = this.getPrintDom(res.data);
  1874. this.detailShow = true;
  1875. this.$nextTick(() => {
  1876. this.$refs.detailTable.innerHTML = this.printDomData;
  1877. });
  1878. } else {
  1879. this.$message.error(res.msg);
  1880. }
  1881. } catch (error) {
  1882. console.log(error);
  1883. }
  1884. },
  1885. // 提交 回调
  1886. async handleSubmit(row) {
  1887. this.deliverShow = true;
  1888. this.$nextTick(() => {
  1889. this.$refs.deliverRef.productInvoiceInfo(row);
  1890. });
  1891. },
  1892. // 取消提交
  1893. async handleSubmitCancel(row) {
  1894. console.log(row);
  1895. this.$confirm("此操作将撤回该次提交, 是否继续?", "提示", {
  1896. confirmButtonText: "确定",
  1897. cancelButtonText: "取消",
  1898. type: "warning",
  1899. })
  1900. .then(async () => {
  1901. // this.$message({
  1902. // type: 'success',
  1903. // message: '删除成功!'
  1904. // });
  1905. try {
  1906. let { saleNo } = row;
  1907. let payLoad = {
  1908. saleOrderNo: saleNo,
  1909. status: 1,
  1910. };
  1911. let res = await cancelRetailOrder(payLoad);
  1912. if (res.code == 200) {
  1913. this.$message.success("取消成功");
  1914. this.getList();
  1915. } else {
  1916. this.$message.error("取消失败");
  1917. console.log(res);
  1918. }
  1919. } catch (error) {
  1920. console.log(error);
  1921. }
  1922. })
  1923. .catch(() => {
  1924. this.$message({
  1925. type: "info",
  1926. message: "已取消",
  1927. });
  1928. });
  1929. },
  1930. // 获取打印dom
  1931. getPrintDom(data) {
  1932. let {
  1933. id,
  1934. //订单表数据
  1935. saleNo,
  1936. saleCustomNo,
  1937. saleDate,
  1938. saleOrderEstimatedTime,
  1939. saleLeadTime,
  1940. deliveryDate,
  1941. saleAmounts,
  1942. saleAmountInWords,
  1943. salePayType,
  1944. salesman,
  1945. customAddress,
  1946. customCountryType, //国家类型
  1947. contactPerson, //联系人
  1948. // 工艺表数据
  1949. orderRemark,
  1950. } = this.formData;
  1951. this.productionTableData;
  1952. let customData = this.customerOptions.find(
  1953. (item) => item.customNo == saleCustomNo
  1954. );
  1955. let customerName = customData ? customData.customName : "";
  1956. let printStr = `
  1957. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  1958. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  1959. <div style="text-align:center;">销售合同审计单</div>
  1960. <tbody>
  1961. <tr>
  1962. <td width="600px" colspan="4">合同号:${saleNo}</td>
  1963. <td width="600px" colspan="4">日期:${saleDate.replace(
  1964. "T",
  1965. " "
  1966. )}</td>
  1967. </tr>
  1968. <tr align="center">
  1969. <td width="300px" colspan="2">客户名称:</td>
  1970. <td width="300px" colspan="2">${customerName}</td>
  1971. <td colspan="2">业务员:</td>
  1972. <td colspan="2">${salesman}</td>
  1973. </tr>
  1974. <tr align="center">
  1975. <td width="300px" colspan="2">客户地址:</td>
  1976. <td width="300px" colspan="2">${customAddress}</td>
  1977. <td width="300px" colspan="2">客户国别:</td>
  1978. <td width="300px" colspan="2">${customCountryType}</td>
  1979. </tr>
  1980. <tr align="center">
  1981. <td width="300px" colspan="2">联系人:</td>
  1982. <td width="150px" colspan="1">${contactPerson}</td>
  1983. <td colspan="2">合计金额(大写):</td>
  1984. <td colspan="3">${saleAmountInWords}</td>
  1985. </tr>
  1986. <tr align="center">
  1987. <td colspan="8">货品明细</td>
  1988. </tr>
  1989. <tr align="center">
  1990. <td width="150px">品名</td>
  1991. <td width="150px">类型</td>
  1992. <td width="150px">箱数</td>
  1993. <td width="150px">单价</td>
  1994. <td width="150px">金额</td>
  1995. <td width="150px">切片型号</td>
  1996. <td width="150px">色号</td>
  1997. <td width="150px">备注</td>
  1998. </tr>`;
  1999. let amountTotal = 0,
  2000. singlTotal = 0,
  2001. moneyTotal = 0;
  2002. for (let i = 0; i < this.productionTableData.length; i++) {
  2003. let item = this.productionTableData[i];
  2004. amountTotal += Number(item.productNumber);
  2005. singlTotal += Number(item.productUnitPrice);
  2006. moneyTotal += Number(item.productAmounts);
  2007. let productData = this.productionOptions.find(
  2008. (pro) => pro.productNo == item.productNo
  2009. );
  2010. item.sliceTypeLabel =
  2011. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  2012. ?.materielName || "";
  2013. item.colourNumberLabel = this.colourNumberOptions.find(
  2014. (k) => k.materielCode == item.colourNumber
  2015. )?.materieColorNumber;
  2016. let productName = productData ? productData.productName : "";
  2017. let productType = productData ? productData.productType : "";
  2018. printStr += `<tr align="center">
  2019. <td>${productName}</td>
  2020. <td>${productType}</td>
  2021. <td>${item.productNumber}</td>
  2022. <td>${item.productUnitPrice}</td>
  2023. <td>${item.productAmounts}</td>
  2024. <td>${item.sliceTypeLabel}</td>
  2025. <td>${item.colourNumberLabel}</td>
  2026. <td>${item.remark}</td>
  2027. </tr>`;
  2028. }
  2029. // 计算小计
  2030. amountTotal = amountTotal.toFixed(2);
  2031. singlTotal = singlTotal.toFixed(2);
  2032. moneyTotal = moneyTotal.toFixed(2);
  2033. printStr += `
  2034. <tr align="center">
  2035. <td>小计:</td>
  2036. <td></td>
  2037. <td>${amountTotal}</td>
  2038. <td>${singlTotal}</td>
  2039. <td>${moneyTotal}</td>
  2040. <td></td>
  2041. <td></td>
  2042. <td></td>
  2043. </tr>`;
  2044. printStr += `<tr align="left">
  2045. <td colspan="8">订单备注:${orderRemark}</td>
  2046. </tr>
  2047. </tbody>
  2048. </table>`;
  2049. return printStr;
  2050. },
  2051. // 添加真正的字段名
  2052. addRealFieldName(row) {
  2053. let fieldList = Object.keys(row);
  2054. // let tableName = this.longestCommonSubstring(fieldList);
  2055. let tableName = camelCase(this.tableName);
  2056. fieldList.forEach((field) => {
  2057. let realField = field.replace(tableName, "");
  2058. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  2059. row[realField] = row[field];
  2060. });
  2061. },
  2062. /** 提交按钮 */
  2063. submitForm: function () {
  2064. this.$refs["form"].validate((valid) => {
  2065. if (valid) {
  2066. if (this.form.userId != undefined) {
  2067. updateUser(this.form).then((response) => {
  2068. this.$modal.msgSuccess("修改成功");
  2069. this.open = false;
  2070. this.getList();
  2071. });
  2072. } else {
  2073. addUser(this.form).then((response) => {
  2074. this.$modal.msgSuccess("新增成功");
  2075. this.open = false;
  2076. this.getList();
  2077. });
  2078. }
  2079. }
  2080. });
  2081. },
  2082. /** 删除按钮操作
  2083. *
  2084. * 删除提示信息语句(标识)
  2085. * */
  2086. handleDelete(row, btnData) {
  2087. let delIds = this.ids;
  2088. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2089. // let realyKey=
  2090. this.addRealFieldName(row);
  2091. if (row[primary] != undefined && row[primary] != null) {
  2092. delIds = [];
  2093. delIds.push(row[primary]);
  2094. }
  2095. let data = {
  2096. basicMap: {
  2097. btnType: btnData.btnType,
  2098. btnKey: btnData.btnKey,
  2099. tableName: this.tableName,
  2100. },
  2101. conditionMap: {
  2102. // id: delIds,
  2103. },
  2104. btnParametersMap: {},
  2105. };
  2106. if (this.currentBtnData.btnParams) {
  2107. let btnParams =
  2108. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2109. let conditionData =
  2110. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2111. conditionData.forEach((item) => {
  2112. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2113. ? item.fieldValue
  2114. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2115. });
  2116. btnParams.forEach((item) => {
  2117. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  2118. ? item.fieldValue
  2119. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2120. });
  2121. }
  2122. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2123. this.$modal
  2124. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2125. .then(function () {
  2126. // return delTableData(data);
  2127. return btnCommonApi(data);
  2128. })
  2129. .then(() => {
  2130. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2131. this.$refs.mychild.pageList();
  2132. this.$modal.msgSuccess("删除成功");
  2133. })
  2134. .catch(() => {});
  2135. },
  2136. // 批量删除接口
  2137. handleBatchDelete() {
  2138. let delIds = this.ids;
  2139. let primary = camelCase(this.templateInfo.template?.primaryKey);
  2140. // if (row && row[primary] != undefined && row[primary] != null) {
  2141. // delIds = [];
  2142. // delIds.push(row[primary]);
  2143. // }
  2144. let data = {
  2145. basicMap: {
  2146. tableName: this.tableName,
  2147. },
  2148. conditionMap: {
  2149. // id: delIds,
  2150. },
  2151. };
  2152. // if (this.currentBtnData.btnParams) {
  2153. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  2154. // btnParams.forEach((item) => {
  2155. // data.btnParametersMap[
  2156. // this.formatField(item.fieldName, camelCase(this.tableName))
  2157. // ] = item.fieldValue
  2158. // ? item.fieldValue
  2159. // : this.currentRow[item.fieldName];
  2160. // });
  2161. // }
  2162. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  2163. this.$modal
  2164. .confirm('是否确认删除"' + delIds + '"的数据项?')
  2165. .then(function () {
  2166. return delTableData(data);
  2167. // return btnCommonApi(data);
  2168. })
  2169. .then(() => {
  2170. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2171. this.$refs.mychild.pageList();
  2172. this.$modal.msgSuccess("删除成功");
  2173. })
  2174. .catch(() => {});
  2175. },
  2176. /** 导出按钮操作 */
  2177. handleExport() {
  2178. let primary = "saleOrderId";
  2179. let realyKey = "saleOrderId";
  2180. if (this.myDelIds.length > 0) {
  2181. this.queryParams["execlMap"] = [];
  2182. this.myDelIds.forEach((item) => {
  2183. this.queryParams.execlMap.push(
  2184. this.tableList.find((ttem) => {
  2185. return ttem[realyKey] === item;
  2186. })
  2187. );
  2188. });
  2189. } else {
  2190. this.$message.warning("请至少勾选一条导出数据");
  2191. return;
  2192. }
  2193. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  2194. this.download(
  2195. process.env.VUE_APP_BASE_API1 + "common/export",
  2196. {
  2197. ...this.queryParams,
  2198. },
  2199. `文件名称_${new Date().getTime()}.xlsx`
  2200. );
  2201. },
  2202. /** 导入按钮操作 */
  2203. handleImport() {
  2204. this.upload.title = "当前导入";
  2205. this.upload.open = true;
  2206. },
  2207. /** 下载模板操作 */
  2208. importTemplate() {
  2209. this.download(
  2210. process.env.VUE_APP_BASE_API1 +
  2211. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  2212. {},
  2213. `下载模版名称${new Date().getTime()}.xlsx`
  2214. );
  2215. },
  2216. // 文件上传中处理
  2217. handleFileUploadProgress(event, file, fileList) {
  2218. this.upload.isUploading = true;
  2219. },
  2220. // 文件上传成功处理
  2221. handleFileSuccess(response, file, fileList) {
  2222. this.upload.open = false;
  2223. this.upload.isUploading = false;
  2224. this.$refs.upload.clearFiles();
  2225. this.$alert(
  2226. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  2227. response.msg +
  2228. "</div>",
  2229. "导入结果",
  2230. { dangerouslyUseHTMLString: true }
  2231. );
  2232. this.$refs.mychild.pageList({
  2233. limit: this.queryParams.pageSize,
  2234. page: this.queryParams.pageNum,
  2235. });
  2236. },
  2237. //重点在这里
  2238. handleChange(file, fileList) {
  2239. file.name = this.tableName + "." + file.name.split(".")[1];
  2240. fileList.forEach((item) => {
  2241. item.name = this.tableName + "." + file.name.split(".")[1];
  2242. });
  2243. let newFile = new File(
  2244. [file],
  2245. this.tableName + "." + file.name.split(".")[1]
  2246. ); //创建出来也是不可编辑的file对象
  2247. },
  2248. // 提交上传文件
  2249. submitFileForm() {
  2250. this.$refs.upload.submit();
  2251. },
  2252. // 弹窗新增的数
  2253. addListHandler(val) {
  2254. this.addLists.push(...val);
  2255. },
  2256. // 绑定弹窗Dialog确定按钮
  2257. async btnComfirm() {
  2258. let res = await this.$refs.deliverRef.getAllData();
  2259. let { flag, isEdit, data } = res;
  2260. if (flag) {
  2261. // if (isEdit) {
  2262. // //编辑
  2263. // let payLoad = {
  2264. // ...data.formData,
  2265. // saleProductInfoList: data.tableData,
  2266. // };
  2267. // let res = await updateProductInvoice(payLoad);
  2268. // if (res.code == 200) {
  2269. // this.$message.success("修改成功");
  2270. // this.deliverShow = false;
  2271. // this.getList();
  2272. // } else {
  2273. // this.$message.error("网络异常");
  2274. // }
  2275. // } else {
  2276. //新增
  2277. let payLoad = {
  2278. ...data.formData,
  2279. saleProductInfoList: data.tableData,
  2280. };
  2281. payLoad.status = 5;
  2282. // let res = await addProductInvoice(payLoad);
  2283. let res = await submitRetailOrder(payLoad);
  2284. if (res.code == 200) {
  2285. this.$message.success("提交成功");
  2286. this.deliverShow = false;
  2287. this.getList();
  2288. } else {
  2289. this.$message.error("网络异常");
  2290. }
  2291. // }
  2292. }
  2293. },
  2294. // 保存提交数据
  2295. async btnSave() {
  2296. let res = await this.$refs.deliverRef.getAllData();
  2297. let { flag, isEdit, data } = res;
  2298. if (flag) {
  2299. let payLoad = {
  2300. ...data.formData,
  2301. saleProductInfoList: data.tableData,
  2302. };
  2303. payLoad.status = 1;
  2304. let res = await updateProductInvoice(payLoad);
  2305. if (res.code == 200) {
  2306. this.$message.success("保存成功");
  2307. this.deliverShow = false;
  2308. this.getList();
  2309. } else {
  2310. this.$message.error("网络异常");
  2311. }
  2312. // }
  2313. }
  2314. },
  2315. // 去掉表名 开头字母小写
  2316. formatField(field = "", tableName) {
  2317. let temp = field.replace(tableName, "");
  2318. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  2319. },
  2320. //提交编辑结果按钮回调
  2321. async editConfirmHandler() {
  2322. if (this.$refs.addFromRef) {
  2323. this.$refs.addFromRef
  2324. .getData()
  2325. .then(async (values) => {
  2326. let data = {
  2327. basicMap: {
  2328. tableName: this.tableName,
  2329. // btnKey: btnData.btnKey,
  2330. btnKey: this.currentBtnData.btnKey,
  2331. },
  2332. addListMap: [values],
  2333. conditionMap: {},
  2334. commMap: {},
  2335. btnParametersMap: {},
  2336. };
  2337. if (this.currentBtnData.btnParams) {
  2338. let btnParams =
  2339. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  2340. [];
  2341. let conditionData =
  2342. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2343. // let
  2344. btnParams.forEach((item) => {
  2345. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2346. item.fieldValue
  2347. ? item.fieldValue
  2348. : this.currentRow[
  2349. camelCase(item.fieldName.replace(".", "_"))
  2350. ];
  2351. });
  2352. conditionData.forEach((item) => {
  2353. data.conditionMap[item.fieldName.split(".")[1]] =
  2354. item.fieldValue
  2355. ? item.fieldValue
  2356. : this.currentRow[
  2357. camelCase(item.fieldName.replace(".", "_"))
  2358. ];
  2359. });
  2360. }
  2361. if (Object.keys(this.defaultValue).length) {
  2362. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  2363. // this.defaultValue[this.templateInfo.template?.primaryKey];
  2364. Object.keys(values).map((k) => {
  2365. data.commMap[k] = values[k];
  2366. });
  2367. data.basicMap.btnType = this.currentBtnData.btnType;
  2368. data.basicMap.visible = true;
  2369. } else {
  2370. data.basicMap.btnType = "INSERT";
  2371. data.basicMap.visible = true;
  2372. }
  2373. try {
  2374. let res = await btnCommonApi(data);
  2375. if (res.code == 200) {
  2376. this.$message.success("操作成功");
  2377. } else {
  2378. this.$message.error("网络异常,请稍后再试");
  2379. }
  2380. } catch (error) {
  2381. console.log(error);
  2382. this.$message.error("网络异常,请稍后再试");
  2383. }
  2384. this.getList();
  2385. this.defaultValue = {};
  2386. this.kOpen = false;
  2387. })
  2388. .catch((res) => {
  2389. console.log(res);
  2390. this.$modal.msgError("表单校验失败,请规范填写数据");
  2391. });
  2392. } else {
  2393. // 没有绑定表单
  2394. let data = {
  2395. basicMap: {
  2396. tableName: this.tableName,
  2397. // btnKey: btnData.btnKey,
  2398. btnKey: this.currentBtnData.btnKey,
  2399. btnType: this.currentBtnData.btnType,
  2400. visible: true,
  2401. },
  2402. addListMap: [],
  2403. conditionMap: {},
  2404. commMap: {},
  2405. btnParametersMap: {},
  2406. };
  2407. if (this.currentBtnData.btnParams) {
  2408. let btnParams =
  2409. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2410. let conditionData =
  2411. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2412. conditionData.forEach((item) => {
  2413. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2414. ? item.fieldValue
  2415. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2416. });
  2417. btnParams.forEach((item) => {
  2418. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2419. item.fieldValue
  2420. ? item.fieldValue
  2421. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2422. });
  2423. }
  2424. // data.basicMap.btnType = this.currentBtnData.btnType;
  2425. // data.basicMap.visible = true;
  2426. try {
  2427. let res = await btnCommonApi(data);
  2428. if (res.code == 200) {
  2429. this.$message.success("操作成功");
  2430. } else {
  2431. this.$message.error("网络异常,请稍后再试");
  2432. }
  2433. } catch (error) {
  2434. console.log(error);
  2435. this.$message.error("网络异常,请稍后再试");
  2436. }
  2437. this.getList();
  2438. this.defaultValue = {};
  2439. this.kOpen = false;
  2440. }
  2441. },
  2442. // 使用提交数据类型的按钮获取数据
  2443. tempSubBtn(getData) {
  2444. getData()
  2445. .then((values) => {
  2446. console.log("验证通过", values);
  2447. })
  2448. .catch(() => {
  2449. console.log("验证未通过,获取失败");
  2450. });
  2451. },
  2452. // 判断是否生效行样式
  2453. cellStyle({ row, column, rowIndex, columnIndex }) {
  2454. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2455. if (!rowStyleList.length) return "";
  2456. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2457. for (let i = 0; i < rowStyleList.length; i++) {
  2458. let item = rowStyleList[i];
  2459. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2460. if (judgeRes) {
  2461. let styleCode = JSON.parse(item.styleCode);
  2462. return `background-color:${styleCode.rowBgColor};`;
  2463. }
  2464. }
  2465. },
  2466. // 获取生效条件组结果
  2467. determineCondition(conditionStr, row) {
  2468. let conditionList = JSON.parse(conditionStr);
  2469. if (!conditionList.length) return false;
  2470. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2471. },
  2472. // 获取单个判断条件结果
  2473. judgeOneCondition(item, row) {
  2474. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2475. switch (item.condition) {
  2476. case 1:
  2477. return row[fullField] > item.flagValue;
  2478. case 2:
  2479. return row[fullField] < item.flagValue;
  2480. case 3:
  2481. return row[fullField] == item.flagValue;
  2482. case 4:
  2483. return row[fullField] >= item.flagValue;
  2484. case 5:
  2485. return row[fullField] <= item.flagValue;
  2486. default:
  2487. return true; //默认为true
  2488. }
  2489. },
  2490. // 设置表格字段样式
  2491. async setFieldStyleData(tableList) {
  2492. console.log(JSON.parse(JSON.stringify(tableList)));
  2493. let fieldConditionList = this.styleList.filter(
  2494. (item) => item.styleType == 1 || item.styleType == 2
  2495. );
  2496. if (!fieldConditionList.length) return tableList;
  2497. let res = await this.setDictStyleData();
  2498. this.dictStyleObj = res.reduce((pre, item) => {
  2499. return {
  2500. ...pre,
  2501. ...item,
  2502. };
  2503. }, {});
  2504. // console.log("this.dictStyleObj", this.dictStyleObj);
  2505. tableList.forEach((row) => {
  2506. // if (!row.styleFieldObj) row.styleFieldObj = {};
  2507. for (let i = 0; i < fieldConditionList.length; i++) {
  2508. let item = fieldConditionList[i];
  2509. if (item.styleType == 1) {
  2510. //字段样式
  2511. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2512. if (judgeRes) {
  2513. let styleCode = JSON.parse(item.styleCode);
  2514. if (!row.styleFieldObj) row.styleFieldObj = {};
  2515. row.styleFieldObj[item.styleField] = {
  2516. styleType: item.styleType,
  2517. fieldStyleType: styleCode.fieldStyleType,
  2518. fontColor: styleCode.fontColor,
  2519. isTagFullBg: styleCode.isTagFullBg,
  2520. tagType: styleCode.tagType,
  2521. };
  2522. // row.styleField = item.styleField; //样式生效字段
  2523. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2524. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2525. // row.fontColor = styleCode.fontColor;
  2526. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2527. // row.tagType = styleCode.tagType; //string
  2528. }
  2529. } else {
  2530. //字典样式
  2531. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2532. return dict.dictValue == row[item.styleField];
  2533. });
  2534. if (dicStyle) {
  2535. if (!row.styleFieldObj) row.styleFieldObj = {};
  2536. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2537. row.styleFieldObj[item.styleField].styleType = 2;
  2538. }
  2539. }
  2540. }
  2541. });
  2542. return tableList;
  2543. },
  2544. //设置表格字典相关数据
  2545. setDictStyleData() {
  2546. let fieldConditionList = this.styleList.filter(
  2547. (item) => item.styleType == 2
  2548. );
  2549. if (!fieldConditionList.length) return;
  2550. let PromiseList = fieldConditionList.map((item) => {
  2551. return new Promise((resolve, reject) => {
  2552. let temp = {};
  2553. try {
  2554. listData({
  2555. isEnablePaging: false,
  2556. dictType: item.styleCondtion,
  2557. }).then((res) => {
  2558. temp[item.styleField] = res.rows;
  2559. resolve(temp);
  2560. });
  2561. } catch (error) {
  2562. reject(error);
  2563. }
  2564. });
  2565. });
  2566. return Promise.all(PromiseList);
  2567. },
  2568. // 内链页面跳转
  2569. routerHandler(btnData, type) {
  2570. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2571. let tempArr = [];
  2572. if (commonFieldData) {
  2573. let queryArr = JSON.parse(commonFieldData);
  2574. tempArr = queryArr.map((item) => {
  2575. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2576. let value = item.fieldValue
  2577. ? item.fieldValue
  2578. : this.currentRow[item.fieldName];
  2579. return key + "=" + value;
  2580. });
  2581. }
  2582. if (tempArr.length) {
  2583. url += "?" + tempArr.join("&");
  2584. }
  2585. // let link = btnData.btnParams;
  2586. if (type == "INNERLINK") {
  2587. this.$router.push(url);
  2588. } else {
  2589. window.open("http://" + url, "_blank");
  2590. }
  2591. },
  2592. async handleDetail(row) {
  2593. this.printDomData = await this.getDetailTableString(row);
  2594. this.detailShow = true;
  2595. this.$nextTick(() => {
  2596. this.$refs.detailTable.innerHTML = this.printDomData;
  2597. });
  2598. },
  2599. // 切片类型改变回调
  2600. sliceTypeChangeHandler(row) {
  2601. let { sliceType } = row;
  2602. if (sliceType) {
  2603. row.sliceTypeLabel = this.sliceTypeOptions.find(
  2604. (item) => item.materielCode == sliceType
  2605. )?.materielName;
  2606. }
  2607. },
  2608. // 色号改变回调
  2609. colourNumberChangeHandler(row) {
  2610. let { colourNumber } = row;
  2611. if (colourNumber) {
  2612. let target = this.colourNumberOptions.find(
  2613. (item) => item.materielCode == colourNumber
  2614. );
  2615. if (target) {
  2616. row.colourNumberLabel =
  2617. target.materieEncoding + target.materieColorNumber;
  2618. }
  2619. // row.colourNumberLabel = this.colourNumberOptions.find(
  2620. // (item) => item.materielCode == colourNumber
  2621. // )?.materieColorNumber;
  2622. }
  2623. },
  2624. // 打印回调
  2625. detailPrintHandler() {
  2626. document.body.innerHTML = document.getElementById("printDom").innerHTML =
  2627. this.printDomData;
  2628. window.print(); //打印
  2629. window.location.reload();
  2630. return false;
  2631. },
  2632. // 根据字典value获取字典label
  2633. getDictLabel(value, dict) {
  2634. return (
  2635. this.dict.type[dict].find((item) => {
  2636. return item.value === value;
  2637. })?.label || ""
  2638. );
  2639. },
  2640. // 获取详情html字符串
  2641. async getDetailTableString(row) {
  2642. let { saleOrderSaleNo } = row;
  2643. let payLoad = [
  2644. {
  2645. basicMap: {
  2646. tableName: "sale_order",
  2647. },
  2648. conditionMap: {
  2649. sale_no: [saleOrderSaleNo],
  2650. },
  2651. },
  2652. {
  2653. basicMap: {
  2654. tableName: "sale_products",
  2655. },
  2656. conditionMap: {
  2657. sale_order_no: [saleOrderSaleNo],
  2658. },
  2659. },
  2660. {
  2661. basicMap: {
  2662. tableName: "sale_craft",
  2663. },
  2664. conditionMap: {
  2665. sale_order_no: [saleOrderSaleNo],
  2666. },
  2667. },
  2668. ];
  2669. let res = await queryDropDownBoxData(payLoad);
  2670. if (res.code == 200) {
  2671. console.log(res);
  2672. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  2673. let {
  2674. //订单表数据
  2675. saleNo, //合同号
  2676. lotNumber, //批号
  2677. saleCustomNo, //客户编号
  2678. saleDate, //销售单日期
  2679. saleOrderEstimatedTime, //预计下单时间
  2680. saleLeadTime, //交货周期
  2681. deliveryDate,
  2682. saleAmounts, //合计金额 小写
  2683. saleAmountInWords, //合计金额 大写
  2684. salePayType, //支付方式
  2685. earnestMoney,
  2686. salesman, //业务员
  2687. saleLeader, //业务主管
  2688. finance, //财务部
  2689. production, //生产部
  2690. saleApprover, //批准人
  2691. // customAddress, //客户地址
  2692. // customCountryType, //国家类型
  2693. // contactPerson, //联系人
  2694. // 货品明细表数据
  2695. // productNo, //货品号
  2696. // productName, //货品名称
  2697. // productNumber: "", //销售数量
  2698. // productWeight: "", //销售重量kg
  2699. // productUnitPrice: "", //单价
  2700. // productAmounts: "", //金额
  2701. // remark: "", //备注
  2702. // 工艺表
  2703. craftGrid, //网络
  2704. craftOil, //油剂
  2705. craftPackage, //卷装
  2706. craftColorFastness, //色牢度
  2707. directionOfTwist,
  2708. craftOther, //其它工艺要求
  2709. craftMark, //包装/贴唛
  2710. shippingMethod, //运输方式
  2711. } = { ...sale_craft[0], ...sale_order[0] };
  2712. let customData = this.customerOptions.find(
  2713. (item) => item.customNo == saleCustomNo
  2714. );
  2715. let payType = this.getDictLabel(salePayType, "payment_method"); //付款方式
  2716. let customerName = customData ? customData.customName : "";
  2717. let customAddress = customData?.customAddress || "无";
  2718. let customCountryType = customData?.customCountryType || "";
  2719. let contactPerson = customData?.contactPerson || "无";
  2720. let directionOfTwistDescription = directionOfTwist
  2721. ? this.getDictLabel(directionOfTwist, "direction_of_twist")
  2722. : "";
  2723. let printStr = `
  2724. <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  2725. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  2726. <div style="text-align:center;">销售合同审计单</div>
  2727. <tbody>
  2728. <tr>
  2729. <td width="600px" colspan="4">合同号:${saleNo}</td>
  2730. <td width="600px" colspan="4">日期:${saleDate.replace(
  2731. "T",
  2732. " "
  2733. )}</td>
  2734. </tr>
  2735. <tr align="center">
  2736. <td width="300px" colspan="2">客户名称:</td>
  2737. <td width="300px" colspan="2">${customerName}</td>
  2738. <td width="300px" colspan="2">联系人:</td>
  2739. <td width="150px" colspan="1">${contactPerson}</td>
  2740. </tr>
  2741. <tr align="center">
  2742. <td width="300px" colspan="2">客户地址:</td>
  2743. <td width="300px" colspan="2">${customAddress}</td>
  2744. <td width="300px" colspan="2">客户国别:</td>
  2745. <td width="300px" colspan="2">${customCountryType}</td>
  2746. </tr>
  2747. <tr align="center">
  2748. <td width="300px" colspan="2">预计下单时间:</td>
  2749. <td colspan="1">${saleOrderEstimatedTime.replace(
  2750. "T",
  2751. " "
  2752. )}</td>
  2753. <td colspan="1">交货周期:</td>
  2754. <td >${saleLeadTime}</td>
  2755. <td colspan="2">交货日期:</td>
  2756. <td >${deliveryDate.replace("T", " ")}</td>
  2757. </tr>
  2758. <tr align="center">
  2759. <td colspan="8">货品明细</td>
  2760. </tr>
  2761. <tr align="center">
  2762. <td width="150px">品名</td>
  2763. <td width="150px">类型</td>
  2764. <td width="150px">箱数</td>
  2765. <td width="150px">单价</td>
  2766. <td width="150px">金额</td>
  2767. <td width="150px">切片型号</td>
  2768. <td width="150px">色号</td>
  2769. <td width="150px">备注</td>
  2770. </tr>`;
  2771. let amountTotal = 0,
  2772. singlTotal = 0,
  2773. moneyTotal = 0;
  2774. for (let i = 0; i < sale_products.length; i++) {
  2775. let item = sale_products[i];
  2776. amountTotal += Number(item.productNumber);
  2777. singlTotal += Number(item.productUnitPrice);
  2778. moneyTotal += Number(item.productAmounts);
  2779. let productData = this.productionOptions.find(
  2780. (pro) => pro.productNo == item.productNo
  2781. );
  2782. console.log("item", item);
  2783. item.sliceTypeLabel =
  2784. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  2785. ?.materielName || "";
  2786. item.colourNumberLabel = this.colourNumberOptions.find(
  2787. (k) => k.materielCode == item.colourNumber
  2788. )?.materieColorNumber;
  2789. let productName = productData ? productData.productName : "";
  2790. let productType = productData ? productData.productType : "";
  2791. printStr += `<tr align="center">
  2792. <td>${productName}</td>
  2793. <td>${productType}</td>
  2794. <td>${item.productNumber}</td>
  2795. <td>${item.productUnitPrice}</td>
  2796. <td>${item.productAmounts}</td>
  2797. <td>${item.sliceTypeLabel}</td>
  2798. <td>${item.colourNumberLabel}</td>
  2799. <td>${item.remark}</td>
  2800. </tr>`;
  2801. }
  2802. // 计算小计
  2803. printStr += `
  2804. <tr align="center">
  2805. <td>小计:</td>
  2806. <td></td>
  2807. <td>${amountTotal}</td>
  2808. <td>${singlTotal}</td>
  2809. <td>${moneyTotal}</td>
  2810. <td></td>
  2811. <td></td>
  2812. <td></td>
  2813. </tr>
  2814. <tr>
  2815. <td colspan="8">合计金额(大写):${saleAmountInWords}</td>
  2816. </tr>
  2817. `;
  2818. if (salePayType == "1") {
  2819. //定金
  2820. printStr += `
  2821. <tr>
  2822. <td colspan="4">付款方式:${payType}</td>
  2823. <td colspan="4">定金:${earnestMoney}</td>
  2824. </tr>`;
  2825. } else {
  2826. printStr += `
  2827. <tr>
  2828. <td colspan="8">付款方式:${payType}</td>
  2829. </tr>`;
  2830. }
  2831. printStr += `<tr align="center">
  2832. <td colspan="8">工艺要求</td>
  2833. </tr>
  2834. <tr align="center">
  2835. <td width="150px">网络</td>
  2836. <td width="150px">油剂</td>
  2837. <td width="150px">卷装</td>
  2838. <td width="150px">色牢度</td>
  2839. <td width="150px">捻向</td>
  2840. <td width="150px">其他</td>
  2841. <td width="150px"></td>
  2842. <td width="150px"></td>
  2843. </tr>
  2844. <tr align="center">
  2845. <td >${craftGrid}</td>
  2846. <td>${craftOil}</td>
  2847. <td>${craftPackage}</td>
  2848. <td>${craftColorFastness}</td>
  2849. <td>${directionOfTwistDescription}</td>
  2850. <td>${craftOther}</td>
  2851. <td width="150px"></td>
  2852. <td width="150px"></td>
  2853. </tr>
  2854. <tr>
  2855. <td colspan="8">包装/贴唛:${craftMark}</td>
  2856. </tr>
  2857. <tr>
  2858. <td colspan="8">装运方式:${shippingMethod}</td>
  2859. </tr>
  2860. <tr align="center">
  2861. <td colspan="2">业务员:</td>
  2862. <td colspan="2">${salesman}</td>
  2863. <td colspan="2">财务部:</td>
  2864. <td colspan="2">${finance}</td>
  2865. </tr>
  2866. <tr align="center">
  2867. <td colspan="2">业务主管:</td>
  2868. <td colspan="2">${saleApprover}</td>
  2869. <td></td>
  2870. <td></td>
  2871. <td></td>
  2872. <td></td>
  2873. </tr>
  2874. </tbody>
  2875. </table>
  2876. `;
  2877. return printStr;
  2878. // <td colspan="2">业务主管:</td>
  2879. // <td colspan="2">${saleLeader}</td>
  2880. // <tr align="center">
  2881. // // <td colspan="2">生产部:</td>
  2882. // // <td colspan="2">${production}</td>
  2883. // </tr>
  2884. // <tr align="center">
  2885. // <td colspan="2"> 2</td>
  2886. // <td> </td>
  2887. // <td> </td>
  2888. // <td> </td>
  2889. // <td> </td>
  2890. // </tr>
  2891. // <tr>
  2892. // <td colspan="2">小计:</td>
  2893. // <td></td>
  2894. // <td></td>
  2895. // <td></td>
  2896. // <td></td>
  2897. // </tr>
  2898. }
  2899. },
  2900. // 自定义删除按钮
  2901. async myDeleteHandler(row) {
  2902. console.log(row);
  2903. let stateArr = ["2", "3", "4", "5", "6", "8"];
  2904. let isDeleteValidate = this.selection.some((item) => {
  2905. return stateArr.includes(item.status);
  2906. });
  2907. console.log(this.selection);
  2908. console.log(isDeleteValidate);
  2909. if (isDeleteValidate) {
  2910. this.$message.error("仅允许删除订单状态为'未提交'或'未通过'的订单");
  2911. return;
  2912. }
  2913. await this.$confirm("是否确认删除选中的数据?", "警告", {
  2914. confirmButtonText: "确定",
  2915. cancelButtonText: "取消",
  2916. type: "warning",
  2917. });
  2918. let payLoad = row.saleOrderId ? [row.saleOrderId] : this.myDelIds;
  2919. console.log(payLoad);
  2920. try {
  2921. let res = await delOrder(payLoad);
  2922. if (res.code === 200) {
  2923. this.$message.success("删除成功");
  2924. this.getList();
  2925. this.myDelIds = [];
  2926. // this.$nextTick(() => {
  2927. // this.$refs.tableRef?.clearSelection();
  2928. // });
  2929. } else {
  2930. this.$message.error(res.msg);
  2931. }
  2932. } catch (error) {}
  2933. },
  2934. // 发货回调
  2935. myDeliverHandler(row) {
  2936. this.currentRow = row;
  2937. this.deliverShow = true;
  2938. this.$nextTick(() => {
  2939. this.$refs.deliverRef.productInvoiceInfo(row);
  2940. });
  2941. },
  2942. },
  2943. };
  2944. </script>
  2945. <style scoped lang="scss">
  2946. ::v-deep .el-dialog:not(.is-fullscreen) {
  2947. min-width: 610px !important;
  2948. }
  2949. </style>