index.vue 113 KB

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