index.vue 93 KB

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