index.vue 124 KB

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