index.vue 103 KB

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