index.vue 119 KB

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