index.vue 112 KB

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