approve.vue 94 KB

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