index.vue 114 KB

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