26f5ff872bce6a9cd273a2a3c91cbc91e3e4528a.svn-base 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-button class="import" style="float: right;margin-right: 80px;" @click="handleImport">导入</el-button>
  13. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  14. </div>
  15. <div class="search">
  16. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  17. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  18. </el-select>
  19. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  21. </el-select>
  22. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  24. </el-select>
  25. <div ref="selectInput" class="filter-item selectInput">
  26. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  27. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  28. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  29. <ul v-if="arrowUp" class="selectUl">
  30. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  31. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  32. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  33. <li>
  34. <div style="float: right;">
  35. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  36. <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
  37. </div>
  38. </li>
  39. </ul>
  40. </div>
  41. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  42. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  43. </div>
  44. <div class="table">
  45. <el-table
  46. :key="table.tableKey"
  47. v-loading="table.listLoading"
  48. element-loading-text="给我一点时间"
  49. :data="table.list"
  50. border
  51. fit
  52. highlight-current-row
  53. style="width: 98%;"
  54. :row-style="rowStyle"
  55. :cell-style="cellStyle"
  56. class="elTable table-fixed"
  57. @row-click="tableRowClick"
  58. @selection-change="handleSelectionChange"
  59. >
  60. <el-table-column type="selection" align="center" width="50" />
  61. <el-table-column label="序号" align="center" type="index" width="50px">
  62. <template slot-scope="scope">
  63. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="配方名称" min-width="130px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  69. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="配方颜色" min-width="130px" align="center">
  73. <template slot-scope="scope">
  74. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="牲畜类别" min-width="150px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  80. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  81. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="配方类型" min-width="150px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  88. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  89. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  90. </el-select>
  91. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  92. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="来源" min-width="110px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.source }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="备注" min-width="110px" align="center">
  102. <template slot-scope="scope">
  103. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  104. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="是否启用" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  113. <template slot-scope="{row}">
  114. <!-- 新增 -->
  115. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  116. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  117. <!-- 编辑 -->
  118. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  119. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  120. <!-- 编辑保存 -->
  121. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  122. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <!-- 配方详情表 -->
  129. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  130. <p class="recipeDetail" />
  131. <div class="operation">
  132. <el-button class="success" @click="handleCreate2">新增</el-button>
  133. <el-button class="danger" @click="handleDelete2">删除</el-button>
  134. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  135. <div ref="selectInput2" class="filter-item selectInput">
  136. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  137. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  138. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  139. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  140. <li>
  141. <a style="width: 130px;">饲料名称</a>
  142. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  143. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  144. </el-select>
  145. </li>
  146. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  147. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  148. <li>
  149. <a style="width: 130px;">搅拌延时</a>
  150. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  151. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  152. </el-select>
  153. </li>
  154. <li>
  155. <a style="width: 130px;">是否锁定牛头数比例</a>
  156. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  157. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  158. </el-select>
  159. </li>
  160. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  161. <li>
  162. <div style="float: right;">
  163. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  164. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  165. </div>
  166. </li>
  167. </ul>
  168. </div>
  169. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  170. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  171. </div>
  172. <div class="table2" style="min-height: 400px;">
  173. <el-table
  174. id="table2"
  175. ref="table2"
  176. :key="table2.tableKey"
  177. v-loading="table2.listLoading"
  178. element-loading-text="给我一点时间"
  179. :data="table2.list"
  180. border
  181. fit
  182. highlight-current-row
  183. style="width: 98%;"
  184. :row-style="rowStyle"
  185. :cell-style="cellStyle"
  186. class="elTable table-fixed"
  187. row-key="id"
  188. show-summary
  189. @selection-change="handleSelectionChange2"
  190. >
  191. <el-table-column type="selection" min-width="50" />
  192. <el-table-column label="序号" align="center" type="index" width="50px" />
  193. <el-table-column label="饲料组" min-width="110px" align="center">
  194. <template slot-scope="scope">
  195. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  196. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="饲料名称" min-width="130px" align="center">
  200. <template slot-scope="scope">
  201. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  202. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  203. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  204. </el-select>
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  208. <template slot-scope="scope">
  209. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  210. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  216. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  217. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  218. </el-select>
  219. </template>
  220. </el-table-column>
  221. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  222. <template slot-scope="scope">
  223. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  224. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  225. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  226. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  227. </el-select>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="顺序" min-width="100px" align="center">
  231. <template slot-scope="scope">
  232. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  233. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  237. <template slot-scope="{row}">
  238. <!-- 新增 -->
  239. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  240. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  241. <!-- 编辑 -->
  242. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  243. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  244. <!-- 编辑保存 -->
  245. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  246. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  247. <!-- 拆分预混料 -->
  248. <el-button v-if="parseInt(row.preftid)>0" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. </div>
  253. </div>
  254. <!-- 配方记录 -->
  255. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  256. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  257. <div ref="templateDialog" class="templateDialog">
  258. <p class="recipeTemplate" />
  259. <div class="operation">
  260. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  261. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  262. </div>
  263. <div class="search">
  264. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  265. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  266. </el-select>
  267. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  268. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  269. </el-select>
  270. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  271. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  272. </el-select>
  273. <div ref="selectInput" class="filter-item selectInput">
  274. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  275. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  276. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  277. <ul v-if="arrowUp" class="selectUl">
  278. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  279. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  280. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  281. <li>
  282. <div style="float: right;">
  283. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  284. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  285. </div>
  286. </li>
  287. </ul>
  288. </div>
  289. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  290. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  291. </div>
  292. <div class="table">
  293. <el-table
  294. :key="template.table.tableKey"
  295. v-loading="template.table.listLoading"
  296. element-loading-text="给我一点时间"
  297. :data="template.table.list"
  298. border
  299. fit
  300. highlight-current-row
  301. style="width: 98%;"
  302. :row-style="rowStyle"
  303. :cell-style="cellStyle"
  304. class="elTable table-fixed"
  305. @row-click="tableRowClickDialog"
  306. >
  307. <el-table-column label="序号" align="center" type="index" width="50px">
  308. <template slot-scope="scope">
  309. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="配方名称" min-width="130px" align="center">
  313. <template slot-scope="scope">
  314. <span>{{ scope.row.tname }}</span>
  315. </template>
  316. </el-table-column>
  317. <el-table-column label="配方颜色" min-width="130px" align="center">
  318. <template slot-scope="scope">
  319. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="牲畜类别" min-width="150px" align="center">
  323. <template slot-scope="scope">
  324. <span>{{ scope.row.ccname }}</span>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="配方类型" min-width="150px" align="center">
  328. <template slot-scope="scope">
  329. <span>{{ scope.row.fttype }}</span>
  330. </template>
  331. </el-table-column>
  332. <el-table-column label="来源" min-width="110px" align="center">
  333. <template slot-scope="scope">
  334. <span>{{ scope.row.source }}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="备注" min-width="110px" align="center">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.remark }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="是否启用" min-width="110px" align="center">
  343. <template slot-scope="scope">
  344. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  345. </template>
  346. </el-table-column>
  347. </el-table>
  348. </div>
  349. </div>
  350. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  351. <p class="recipeDetail" />
  352. <div class="operation">
  353. <div ref="selectInput2" class="filter-item selectInput">
  354. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  355. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  356. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  357. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  358. <li>
  359. <a style="width: 130px;">饲料名称</a>
  360. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  361. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  362. </el-select>
  363. </li>
  364. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  365. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  366. <li>
  367. <a style="width: 130px;">搅拌延时</a>
  368. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  369. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  370. </el-select>
  371. </li>
  372. <li>
  373. <a style="width: 130px;">是否锁定牛头数比例</a>
  374. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  375. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  376. </el-select>
  377. </li>
  378. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  379. <li>
  380. <div style="float: right;">
  381. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  382. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  383. </div>
  384. </li>
  385. </ul>
  386. </div>
  387. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  388. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  389. </div>
  390. <div class="table2">
  391. <el-table
  392. :key="template.table2.tableKey"
  393. v-loading="template.table2.listLoading"
  394. element-loading-text="给我一点时间"
  395. :data="template.table2.list"
  396. border
  397. fit
  398. highlight-current-row
  399. style="width: 98%;"
  400. :row-style="rowStyle"
  401. :cell-style="cellStyle"
  402. class="elTable table-fixed"
  403. row-key="id"
  404. >
  405. <el-table-column label="饲料组" min-width="130px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.feedgroup }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="饲料名称" min-width="130px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.fname }}</span>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="重量(KG)" min-width="130px" align="center">
  416. <template slot-scope="scope">
  417. <span>{{ scope.row.fweight }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  421. <template slot-scope="scope">
  422. <span>{{ scope.row.autosecondname }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  426. <template slot-scope="scope">
  427. <span v-if="scope.row.islockcount == '0'">否</span>
  428. <span v-if="scope.row.islockcount == '1'">是</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="顺序" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.sort }}</span>
  434. </template>
  435. </el-table-column>
  436. </el-table>
  437. </div>
  438. </div>
  439. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  440. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  441. </div>
  442. </div>
  443. </el-dialog>
  444. <!-- 合成预混料 -->
  445. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  446. <div class="detailDialog">
  447. <h2>饲料</h2>
  448. <div class="table1">
  449. <el-table
  450. :key="detail.tableKey"
  451. v-loading="detail.listLoading"
  452. element-loading-text="给我一点时间"
  453. :data="detail.list"
  454. fit
  455. highlight-current-row
  456. style="width: 100%;"
  457. :row-style="rowStyle"
  458. :cell-style="cellStyle"
  459. class="elTable table-fixed"
  460. show-summary
  461. >
  462. <el-table-column label="序号" align="center" type="index" width="50px" />
  463. <el-table-column label="饲料名称" min-width="130px" align="center">
  464. <template slot-scope="scope">
  465. <span>{{ scope.row.fname }}</span>
  466. </template>
  467. </el-table-column>
  468. <el-table-column prop="fweight" sortable label="重量(KG)" />
  469. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.autosecond }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  475. <template slot-scope="scope">
  476. <span v-if="scope.row.islockcount == '0'">否</span>
  477. <span v-if="scope.row.islockcount == '1'">是</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column label="顺序" min-width="110px" align="center">
  481. <template slot-scope="scope">
  482. <span>{{ scope.row.sort }}</span>
  483. </template>
  484. </el-table-column>
  485. </el-table>
  486. </div>
  487. <h2>合成预混料</h2>
  488. <div class="table2" style="margin-bottom: 50px;">
  489. <el-table
  490. :key="detail.tableKey2"
  491. v-loading="detail.listLoading2"
  492. element-loading-text="给我一点时间"
  493. :data="detail.list2"
  494. border
  495. fit
  496. highlight-current-row
  497. style="width: 100%;"
  498. :row-style="rowStyle"
  499. :cell-style="cellStyle"
  500. class="elTable table-fixed"
  501. >
  502. <el-table-column label="配方名称" min-width="130px" align="center">
  503. <template slot-scope="scope">
  504. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="配方颜色" min-width="130px" align="center">
  508. <template slot-scope="scope">
  509. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="牲畜类别" min-width="130px" align="center">
  513. <template slot-scope="scope">
  514. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  515. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  516. </el-select>
  517. </template>
  518. </el-table-column>
  519. <el-table-column label="配方类型" min-width="110px" align="center">
  520. <template slot-scope="scope">
  521. <span>{{ scope.row.fttype }}</span>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="来源" min-width="110px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.source }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column label="备注" min-width="130px" align="center">
  530. <template slot-scope="scope">
  531. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  532. </template>
  533. </el-table-column>
  534. <el-table-column label="是否启用" min-width="130px" align="center">
  535. <template slot-scope="scope">
  536. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  537. </template>
  538. </el-table-column>
  539. </el-table>
  540. </div>
  541. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  542. <el-button class="cancel" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  543. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  544. </div>
  545. </div>
  546. </el-dialog>
  547. </div>
  548. </template>
  549. <script>
  550. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  551. import Sortable from 'sortablejs'
  552. import { MessageBox } from 'element-ui'
  553. import Cookies from 'js-cookie'
  554. export default {
  555. name: 'RecipeTemplate',
  556. data() {
  557. return {
  558. requestParams: [
  559. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  560. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  561. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  562. ],
  563. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  564. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  565. livestockTypeList: [], // 牲畜类别
  566. formulaTypeList: [], // 配方类型
  567. feedNameList: [], // 饲料名称
  568. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  569. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  570. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  571. arrowDown: true,
  572. arrowUp: false,
  573. table: {
  574. getdataListParm: {
  575. name: 'getFTList',
  576. page: 1,
  577. offset: 1,
  578. pagecount: 30,
  579. returntype: 'Map',
  580. parammaps: {
  581. pastureid: Cookies.get('pastureid'),
  582. tname: '',
  583. ccid: '',
  584. ccname: '',
  585. fttypeid: '',
  586. fttype: '',
  587. remark: '',
  588. enable: ''
  589. }
  590. },
  591. tableKey: 0,
  592. list: [],
  593. total: 0,
  594. listLoading: true,
  595. temp: {}
  596. },
  597. lockCount: {
  598. getdataListParm: {
  599. name: 'getSysoptEnable',
  600. page: 1,
  601. offset: 1,
  602. pagecount: 30,
  603. returntype: 'Map',
  604. parammaps: {
  605. pastureid: Cookies.get('pastureid'),
  606. inforname: 'isLockCount'
  607. }
  608. },
  609. isLockCount: false // 是否显示是否锁定牛头数比例
  610. },
  611. isDetail: false,
  612. arrowDown2: true,
  613. arrowUp2: false,
  614. table2: {
  615. getdataListParm: {
  616. name: 'getFTdetailList',
  617. page: 1,
  618. offset: 1,
  619. pagecount: 10,
  620. returntype: 'Map',
  621. parammaps: {
  622. pastureid: Cookies.get('pastureid'),
  623. fname: '',
  624. feedgroup: '',
  625. fweight: '',
  626. autosecondname: '',
  627. islockcount: '',
  628. sort: ''
  629. }
  630. },
  631. tableKey: 0,
  632. list: [],
  633. total: 0,
  634. listLoading: true,
  635. temp: {}
  636. },
  637. isDetailDialog: false,
  638. template: {
  639. dialogFormVisible: false,
  640. dialogStatus: '',
  641. table: {
  642. getdataListParm: {
  643. name: 'getFTListDate',
  644. page: 1,
  645. offset: 1,
  646. pagecount: 10,
  647. returntype: 'Map',
  648. parammaps: {
  649. pastureid: Cookies.get('pastureid'),
  650. tname: '',
  651. ccid: '',
  652. ccname: '',
  653. fttype: '',
  654. remark: '',
  655. enable: '',
  656. date: '',
  657. source: ''
  658. }
  659. },
  660. tableKey: 0,
  661. total: 0,
  662. listLoading: true,
  663. list: []
  664. },
  665. table2: {
  666. getdataListParm: {
  667. name: 'getFTdetailListDate',
  668. page: 1,
  669. offset: 1,
  670. pagecount: 10,
  671. returntype: 'Map',
  672. parammaps: {
  673. pastureid: Cookies.get('pastureid'),
  674. fname: '',
  675. fweight: '',
  676. islockcount: '',
  677. sort: '',
  678. feedgroup: '',
  679. autosecondname: ''
  680. }
  681. },
  682. tableKey: 0,
  683. total: 0,
  684. listLoading: true,
  685. list: []
  686. },
  687. // 历史日期
  688. getdataDateParm: {
  689. name: 'getFTMaxDate',
  690. page: 1,
  691. offset: 1,
  692. pagecount: 10,
  693. returntype: 'Map',
  694. parammaps: {
  695. pastureid: Cookies.get('pastureid')
  696. }
  697. }
  698. },
  699. detail: {
  700. dialogFormVisible: false,
  701. dialogStatus: '',
  702. tableKey: 0,
  703. total: 0,
  704. listLoading: true,
  705. list: [],
  706. tableKey2: 0,
  707. total2: 0,
  708. listLoading2: false,
  709. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  710. getdataListParm: {
  711. name: 'getFTDetailCompare',
  712. page: 1,
  713. offset: 1,
  714. pagecount: 10,
  715. returntype: 'Map',
  716. parammaps: {}
  717. },
  718. list3: [],
  719. disabled: false,
  720. getdataListParm2: {
  721. name: 'getFTCompare',
  722. page: 1,
  723. offset: 1,
  724. pagecount: 10,
  725. returntype: 'Map',
  726. parammaps: {}
  727. }
  728. },
  729. selectList: [],
  730. selectList2: [],
  731. textMap: {
  732. RecipeRecord: '配方记录',
  733. SyntheticPremix: '合成预混料'
  734. },
  735. requestParam: {},
  736. isokDisable: false,
  737. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  738. cellStyle: { padding: 0 + 'px' }
  739. }
  740. },
  741. mounted() {
  742. document.addEventListener('click', (e) => {
  743. if (this.$refs.selectInput !== undefined) {
  744. if (!this.$refs.selectInput.contains(e.target)) {
  745. this.arrowDown = true
  746. this.arrowUp = false
  747. } else {
  748. this.arrowDown = false
  749. this.arrowUp = true
  750. }
  751. }
  752. if (this.$refs.selectInput2 !== undefined) {
  753. if (!this.$refs.selectInput2.contains(e.target)) {
  754. this.arrowDown2 = true
  755. this.arrowUp2 = false
  756. } else {
  757. this.arrowDown2 = false
  758. this.arrowUp2 = true
  759. }
  760. }
  761. })
  762. },
  763. created() {
  764. this.getList()
  765. this.getDownList()
  766. this.getIsLockCount()
  767. },
  768. methods: {
  769. handleHistory() {
  770. MessageBox.confirm('是否确认生成历史?', {
  771. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  772. }).then(() => {
  773. this.requestParam.name = 'creatFTdate'
  774. this.requestParam.parammaps = {}
  775. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  776. PostDataByName(this.requestParam).then(response => {
  777. console.log('生成历史保存发送参数', this.requestParam)
  778. if (response.msg !== 'fail') {
  779. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  780. } else {
  781. failproccess(response, this.$notify)
  782. }
  783. })
  784. })
  785. },
  786. getDownList() {
  787. GetDataByNames(this.requestParams).then(response => {
  788. this.livestockTypeList = response.data.getDictByName.list
  789. this.formulaTypeList = response.data.getDictByName2.list
  790. this.feedNameList = response.data.getFeedAndPre.list
  791. })
  792. },
  793. // -------------------模板-----------------------------
  794. getList() {
  795. this.table.listLoading = true
  796. GetDataByName(this.table.getdataListParm).then(response => {
  797. console.log('table数据', response.data.list)
  798. if (response.data.list !== null) {
  799. for (let i = 0; i < response.data.list.length; i++) {
  800. this.$set(response.data.list[i], 'Edit', false) // 编辑
  801. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  802. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  803. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  804. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  805. }
  806. this.table.list = response.data.list
  807. this.table.pageNum = response.data.pageNum
  808. this.table.pageSize = response.data.pageSize
  809. this.table.total = response.data.total
  810. } else {
  811. this.table.list = []
  812. }
  813. setTimeout(() => {
  814. this.table.listLoading = false
  815. }, 100)
  816. })
  817. },
  818. handleSearch() {
  819. console.log('点击了查询')
  820. this.table.getdataListParm.offset = 1
  821. this.getList()
  822. this.arrowDown = true
  823. this.arrowUp = false
  824. },
  825. handleRefresh() {
  826. console.log('点击了重置')
  827. this.table.getdataListParm.offset = 1
  828. this.table.getdataListParm.parammaps.ccid = ''
  829. this.table.getdataListParm.parammaps.ccname = ''
  830. this.table.getdataListParm.parammaps.fttype = ''
  831. this.table.getdataListParm.parammaps.tname = ''
  832. this.table.getdataListParm.parammaps.remark = ''
  833. this.table.getdataListParm.parammaps.enable = ''
  834. this.table.getdataListParm.parammaps.source = ''
  835. this.getList()
  836. },
  837. // 模板新增
  838. handleCreate() {
  839. console.log('点击了新增')
  840. // 编辑true/不可编辑false
  841. // 新增操true,编辑false,编辑保存false
  842. for (let i = 0; i < this.table.list.length; i++) {
  843. if (this.table.list[i].Edit === true) {
  844. console.log(123)
  845. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  846. return false
  847. }
  848. }
  849. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  850. console.log(this.table.list)
  851. },
  852. // 畜生类别
  853. changeLivestockType(item) {
  854. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  855. },
  856. // 配方类型
  857. changeFormulaType(item) {
  858. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  859. },
  860. createData(row) {
  861. console.log('点击了新增保存', row)
  862. this.table.temp.tname = row.tname
  863. this.table.temp.tcolor = row.tcolor
  864. this.table.temp.ccid = row.ccid
  865. this.table.temp.ccname = this.table.temp.ccname
  866. this.table.temp.fttype = this.table.temp.fttype
  867. this.table.temp.fttypeid = row.fttypeid
  868. this.table.temp.source = row.source
  869. this.table.temp.remark = row.remark
  870. this.table.temp.enable = row.enable
  871. this.table.temp.pastureid = Cookies.get('pastureid')
  872. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  873. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  874. return false
  875. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  876. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  877. return false
  878. } else if (this.table.temp.tname == '') {
  879. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  880. return false
  881. } else if (this.table.temp.ccid == '') {
  882. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  883. return false
  884. } else if (this.table.temp.fttypeid == '') {
  885. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  886. return false
  887. }
  888. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  889. if (pattern.test(this.table.temp.tname)) {
  890. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  891. return false
  892. }
  893. console.log(this.table.temp)
  894. this.isokDisable = true
  895. setTimeout(() => {
  896. this.isokDisable = false
  897. }, 1000)
  898. this.requestParam.name = 'insertFT'
  899. this.requestParam.parammaps = this.table.temp
  900. PostDataByName(this.requestParam).then(response => {
  901. console.log('新增保存发送参数', this.requestParam)
  902. if (response.msg !== 'fail') {
  903. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  904. this.getList()
  905. } else {
  906. failproccess(response, this.$notify)
  907. }
  908. })
  909. },
  910. createCancel(row) {
  911. console.log('点击了新增取消')
  912. for (let i = 0; i < this.table.list.length; i++) {
  913. if (row.myId === this.table.list[i].myId) {
  914. var listIndex = this.table.list.indexOf(this.table.list[i])
  915. }
  916. if (listIndex > -1) {
  917. this.table.list.splice(listIndex, 1)
  918. return
  919. }
  920. }
  921. },
  922. // 模板编辑
  923. handleUpdate(row) {
  924. for (let i = 0; i < this.table.list.length; i++) {
  925. if (this.table.list[i].Edit == true) {
  926. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  927. return false
  928. }
  929. }
  930. // 编辑true,不可编辑false
  931. row.Edit = true
  932. row.NoEdit = false
  933. // 新增false,编辑false,编辑保存true
  934. row.isCreate = false
  935. row.isUpdate = false
  936. row.isUpdateSave = true
  937. row.ccid = String(row.ccid)
  938. row.fttypeid = String(row.fttypeid)
  939. this.table.temp.ccname = row.ccname
  940. this.table.temp.fttype = row.fttype
  941. },
  942. updateData(row) {
  943. console.log('点击了编辑保存', row)
  944. this.table.temp.tname = row.tname
  945. this.table.temp.tcolor = row.tcolor
  946. this.table.temp.ccid = row.ccid
  947. this.table.temp.fttypeid = row.fttypeid
  948. this.table.temp.source = row.source
  949. this.table.temp.remark = row.remark
  950. this.table.temp.enable = row.enable
  951. this.table.temp.ccname = this.table.temp.ccname
  952. this.table.temp.fttype = this.table.temp.fttype
  953. this.table.temp.pastureid = row.pastureid
  954. this.table.temp.id = row.id
  955. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  956. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  957. return false
  958. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  959. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  960. return false
  961. } else if (this.table.temp.tname == '') {
  962. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  963. return false
  964. } else if (this.table.temp.ccid == '') {
  965. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  966. return false
  967. } else if (this.table.temp.fttypeid == '') {
  968. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  969. return false
  970. }
  971. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  972. if (pattern.test(this.table.temp.tname)) {
  973. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  974. return false
  975. }
  976. console.log(this.table.temp)
  977. this.isokDisable = true
  978. setTimeout(() => {
  979. this.isokDisable = false
  980. }, 1000)
  981. this.requestParam.name = 'updateFT'
  982. this.requestParam.parammaps = this.table.temp
  983. PostDataByName(this.requestParam).then(response => {
  984. console.log('新增保存发送参数', this.requestParam)
  985. if (response.msg !== 'fail') {
  986. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  987. this.getList()
  988. } else {
  989. failproccess(response, this.$notify)
  990. }
  991. })
  992. },
  993. updateCancel(row) {
  994. console.log('点击了编辑取消')
  995. // 编辑false,不可编辑true
  996. row.Edit = false
  997. row.NoEdit = true
  998. // 新增false,编辑true,编辑保存false
  999. row.isCreate = false
  1000. row.isUpdate = true
  1001. row.isUpdateSave = false
  1002. },
  1003. // 删除
  1004. handleRowDelete(row) {
  1005. console.log('点击了行内删除')
  1006. MessageBox.confirm('是否确认删除此信息?', {
  1007. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1008. }).then(() => {
  1009. this.selectList = []
  1010. this.requestParam.name = 'deleteFT'
  1011. this.requestParam.parammaps = {}
  1012. this.requestParam.parammaps.pastureid = row.pastureid
  1013. this.requestParam.parammaps.id = row.id
  1014. PostDataByName(this.requestParam).then(response => {
  1015. if (response.msg === 'fail') {
  1016. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1017. } else {
  1018. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1019. this.getList()
  1020. }
  1021. })
  1022. }).catch(() => {
  1023. this.$message({ type: 'info', message: '已取消删除' })
  1024. })
  1025. },
  1026. handleSelectionChange(val) {
  1027. console.log('勾选数据', val)
  1028. this.selectList = val
  1029. },
  1030. handleDelete() {
  1031. console.log('点击了删除')
  1032. if (this.selectList.length == 0) {
  1033. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1034. } else {
  1035. MessageBox.confirm('是否确认删除此信息?', {
  1036. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1037. }).then(() => {
  1038. console.log(this.selectList)
  1039. this.requestParam.common = { 'returnmap': '0' }
  1040. this.requestParam.data = []
  1041. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1042. this.requestParam.data[0].children = []
  1043. this.requestParam.data[0].children[0] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1044. id: '@insertSpotList.id',
  1045. pastureid: '@insertSpotList.pastureid'
  1046. }}
  1047. ExecDataByConfig(this.requestParam).then(response => {
  1048. console.log('删除保存发送参数', this.requestParam)
  1049. if (response.msg === 'fail') {
  1050. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1051. } else {
  1052. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1053. this.getList()
  1054. }
  1055. })
  1056. })
  1057. }
  1058. },
  1059. // 复制
  1060. handleCopy() {
  1061. if (this.selectList.length == 0) {
  1062. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1063. } else {
  1064. MessageBox.confirm('是否确认复制此信息?', {
  1065. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1066. }).then(() => {
  1067. console.log(this.selectList)
  1068. this.requestParam.common = { 'returnmap': '0' }
  1069. this.requestParam.data = []
  1070. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1071. this.requestParam.data[0].children = []
  1072. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1073. ftid: '@insertSpotList.id',
  1074. pastureid: '@insertSpotList.pastureid'
  1075. }}
  1076. ExecDataByConfig(this.requestParam).then(response => {
  1077. console.log('复制保存发送参数', this.requestParam)
  1078. if (response.msg === 'fail') {
  1079. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1080. } else {
  1081. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1082. this.getList()
  1083. }
  1084. })
  1085. })
  1086. }
  1087. },
  1088. // 配方记录
  1089. handleRecipeRecord() {
  1090. console.log('点击了配方记录')
  1091. this.template.dialogStatus = 'RecipeRecord'
  1092. this.template.dialogFormVisible = true
  1093. this.template.table.getdataListParm.parammaps.ccname = ''
  1094. this.template.table.getdataListParm.parammaps.fttype = ''
  1095. this.template.table.getdataListParm.parammaps.enable = ''
  1096. this.template.table.getdataListParm.parammaps.tname = ''
  1097. this.template.table.getdataListParm.parammaps.remark = ''
  1098. this.template.table.getdataListParm.parammaps.source = ''
  1099. this.template.table.getdataListParm.offset = 1
  1100. this.getDateList()
  1101. this.isDetailDialog = false
  1102. },
  1103. // 历史时间
  1104. getDateList() {
  1105. GetDataByName(this.template.getdataDateParm).then(response => {
  1106. console.log('table数据', response.data.list)
  1107. if (response.data.list !== null) {
  1108. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1109. this.getTemplateDialogList()
  1110. } else {
  1111. this.template.table.getdataListParm.parammaps.date = ''
  1112. }
  1113. })
  1114. },
  1115. // 配方记录-模板
  1116. getTemplateDialogList() {
  1117. this.template.table.listLoading = true
  1118. GetDataByName(this.template.table.getdataListParm).then(response => {
  1119. console.log('table数据', response.data.list)
  1120. if (response.data.list !== null) {
  1121. this.template.table.list = response.data.list
  1122. this.template.table.pageNum = response.data.pageNum
  1123. this.template.table.pageSize = response.data.pageSize
  1124. this.template.table.total = response.data.total
  1125. } else {
  1126. this.template.table.list = []
  1127. }
  1128. setTimeout(() => {
  1129. this.template.table.listLoading = false
  1130. }, 100)
  1131. })
  1132. },
  1133. handleDialogSearch() {
  1134. this.template.table.getdataListParm.offset = 1
  1135. this.getTemplateDialogList()
  1136. this.arrowDown = true
  1137. this.arrowUp = false
  1138. },
  1139. handleDialogRefresh() {
  1140. this.template.table.getdataListParm.parammaps.ccname = ''
  1141. this.template.table.getdataListParm.parammaps.fttype = ''
  1142. this.template.table.getdataListParm.parammaps.enable = ''
  1143. this.template.table.getdataListParm.parammaps.tname = ''
  1144. this.template.table.getdataListParm.parammaps.remark = ''
  1145. this.template.table.getdataListParm.parammaps.source = ''
  1146. this.template.table.getdataListParm.offset = 1
  1147. this.getTemplateDialogList()
  1148. },
  1149. // 配方记录-模板行点击
  1150. tableRowClickDialog(row, column, event) {
  1151. console.log('配方记录-模板行点击')
  1152. this.isDetailDialog = true
  1153. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1154. this.getDialogList()
  1155. this.getDownList()
  1156. },
  1157. getDialogList() {
  1158. this.template.table2.listLoading = true
  1159. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1160. console.log('table数据', response.data.list)
  1161. if (response.data.list !== null) {
  1162. this.template.table2.list = response.data.list
  1163. this.template.table2.pageNum = response.data.pageNum
  1164. this.template.table2.pageSize = response.data.pageSize
  1165. this.template.table2.total = response.data.total
  1166. } else {
  1167. this.template.table2.list = []
  1168. }
  1169. setTimeout(() => {
  1170. this.template.table2.listLoading = false
  1171. }, 100)
  1172. })
  1173. },
  1174. handleDialogSearch2() {
  1175. console.log('点击了查询')
  1176. this.arrowDown2 = true
  1177. this.arrowUp2 = false
  1178. this.template.table2.getdataListParm.offset = 1
  1179. this.getDialogList2()
  1180. },
  1181. handleDialogRefresh2() {
  1182. console.log('点击了重置')
  1183. this.template.table2.getdataListParm.parammaps.fname = ''
  1184. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1185. this.template.table2.getdataListParm.parammaps.fweight = ''
  1186. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1187. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1188. this.template.table2.getdataListParm.parammaps.sort = ''
  1189. this.template.table2.getdataListParm.offset = 1
  1190. this.getDialogList2()
  1191. },
  1192. getDialogList2() {
  1193. this.template.table2.listLoading = true
  1194. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1195. console.log('table数据', response.data.list)
  1196. if (response.data.list !== null) {
  1197. this.template.table2.list = response.data.list
  1198. this.template.table2.pageNum = response.data.pageNum
  1199. this.template.table2.pageSize = response.data.pageSize
  1200. this.template.table2.total = response.data.total
  1201. } else {
  1202. this.template.table2.list = []
  1203. }
  1204. this.$nextTick(function() {
  1205. window.scrollTo({
  1206. 'top': this.$refs.templateDialog.clientHeight
  1207. })
  1208. })
  1209. setTimeout(() => {
  1210. this.template.table2.listLoading = false
  1211. }, 100)
  1212. })
  1213. },
  1214. handleImport() {
  1215. console.log('点击了导入')
  1216. },
  1217. handleExport() {
  1218. console.log('点击了导出')
  1219. },
  1220. changeDate() {
  1221. this.getTemplateDialogList()
  1222. },
  1223. // 应用
  1224. handleApplication() {
  1225. console.log('点击了应用')
  1226. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1227. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1228. }).then(() => {
  1229. this.requestParam.name = 'applyFTdate'
  1230. this.requestParam.parammaps = {}
  1231. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1232. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1233. PostDataByName(this.requestParam).then(response => {
  1234. if (response.msg === 'fail') {
  1235. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1236. } else {
  1237. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1238. this.getTemplateDialogList()
  1239. this.getList()
  1240. }
  1241. })
  1242. }).catch(() => {
  1243. this.$message({ type: 'info', message: '已取消应用' })
  1244. })
  1245. },
  1246. // 模板行点击
  1247. tableRowClick(row, column, event) {
  1248. console.log(row, column, event)
  1249. for (let i = 0; i < this.table.list.length; i++) {
  1250. if (this.table.list[i].Edit == true) {
  1251. return false
  1252. }
  1253. }
  1254. if (column.label !== '操作') {
  1255. this.isDetail = true // 点击行显示详情
  1256. this.table2.getdataListParm.parammaps.ftid = row.id
  1257. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1258. this.getList2()
  1259. this.getDownList()
  1260. }
  1261. },
  1262. // -------------------详情-----------------------------
  1263. // 获取是否显示是否锁定牛头数
  1264. getIsLockCount() {
  1265. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1266. console.log(response.data.list)
  1267. if (response.data.list[0].inforvalue == 0) {
  1268. this.lockCount.isLockCount = false
  1269. } else {
  1270. this.lockCount.isLockCount = true
  1271. }
  1272. })
  1273. },
  1274. // 详情
  1275. getList2() {
  1276. this.table2.listLoading = true
  1277. GetDataByName(this.table2.getdataListParm).then(response => {
  1278. console.log('table数据', response.data.list)
  1279. if (response.data.list !== null) {
  1280. for (let i = 0; i < response.data.list.length; i++) {
  1281. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1282. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1283. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1284. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1285. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1286. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1287. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1288. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1289. }
  1290. this.rowDrop()
  1291. this.table2.list = response.data.list
  1292. this.table2.pageNum = response.data.pageNum
  1293. this.table2.pageSize = response.data.pageSize
  1294. this.table2.total = response.data.total
  1295. } else {
  1296. this.table2.list = []
  1297. }
  1298. this.$nextTick(function() {
  1299. console.log(this.$refs)
  1300. console.log(this.$refs.template.clientHeight)
  1301. window.scrollTo({
  1302. 'top': this.$refs.template.clientHeight
  1303. })
  1304. })
  1305. setTimeout(() => {
  1306. this.table2.listLoading = false
  1307. }, 100)
  1308. })
  1309. },
  1310. // 行拖拽
  1311. rowDrop() {
  1312. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1313. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1314. const that = this
  1315. Sortable.create(tbody, {
  1316. onEnd({ newIndex, oldIndex }) {
  1317. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1318. that.table2.list.splice(newIndex, 0, currRow)
  1319. console.log('索引', newIndex)
  1320. console.log('拖动数据', currRow)
  1321. console.log('上', that.table2.list[newIndex - 1])
  1322. console.log('下', that.table2.list[newIndex + 1])
  1323. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1324. for (let i = 0; i < that.table2.list.length; i++) {
  1325. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1326. }
  1327. currRow.sort = 0
  1328. currRow.feedgroup = currRow.fname
  1329. console.log('拖动至最上方无值')
  1330. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1331. currRow.sort = that.table2.list[newIndex - 1].sort
  1332. console.log('拖动值顺序等于上值顺序')
  1333. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1334. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1335. currRow.feedgroup = currRow.fname
  1336. console.log('拖动至最下方无值')
  1337. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1338. currRow.sort == that.table2.list[newIndex + 1].sort
  1339. console.log('拖动值顺序等于下值顺序')
  1340. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1341. currRow.sort = that.table2.list[newIndex - 1].sort
  1342. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1343. console.log('拖动至上下顺序一致')
  1344. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1345. console.log('上下')
  1346. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1347. console.log(newIndex)
  1348. for (let i = newIndex; i < that.table2.list.length; i++) {
  1349. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1350. }
  1351. }
  1352. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1353. currRow.feedgroup = currRow.fname
  1354. console.log(that.table2.list[newIndex + 1].sort)
  1355. }
  1356. that.requestParam = {}
  1357. that.requestParam.common = { 'returnmap': '0' }
  1358. that.requestParam.data = []
  1359. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1360. that.requestParam.data[0].children = []
  1361. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1362. id: '@insertSpotList.id',
  1363. pastureid: '@insertSpotList.pastureid',
  1364. sort: '@insertSpotList.sort',
  1365. feedgroup: '@insertSpotList.feedgroup'
  1366. }}
  1367. ExecDataByConfig(that.requestParam).then(response => {
  1368. console.log('顺序切换保存发送参数', that.requestParam)
  1369. if (response.msg === 'fail') {
  1370. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1371. } else {
  1372. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1373. that.getList2()
  1374. }
  1375. })
  1376. }
  1377. })
  1378. },
  1379. handleSearch2() {
  1380. console.log('点击了查询')
  1381. this.arrowDown2 = true
  1382. this.arrowUp2 = false
  1383. this.table2.getdataListParm.offset = 1
  1384. this.getList2()
  1385. },
  1386. handleRefresh2() {
  1387. console.log('点击了重置')
  1388. this.table2.getdataListParm.parammaps.fname = ''
  1389. this.table2.getdataListParm.parammaps.feedgroup = ''
  1390. this.table2.getdataListParm.parammaps.fweight = ''
  1391. this.table2.getdataListParm.parammaps.autosecondname = ''
  1392. this.table2.getdataListParm.parammaps.islockcount = '0'
  1393. this.table2.getdataListParm.parammaps.sort = ''
  1394. this.table2.getdataListParm.offset = 1
  1395. this.getList2()
  1396. },
  1397. // 详情新增
  1398. handleCreate2() {
  1399. console.log('点击了详情新增', this.table2.list)
  1400. // 编辑true/不可编辑false
  1401. // 新增操true,编辑false,编辑保存false
  1402. console.log(11)
  1403. for (let i = 0; i < this.table2.list.length; i++) {
  1404. if (this.table2.list[i].Edit === true) {
  1405. console.log(123)
  1406. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1407. return false
  1408. }
  1409. }
  1410. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '', 'islockcount': '0', 'sort': '' })
  1411. },
  1412. changeFname(item, row) {
  1413. console.log(item, row)
  1414. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1415. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1416. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1417. this.table2.temp.preftid = '0'
  1418. } else {
  1419. this.table2.temp.preftid = item
  1420. }
  1421. if (row.sort == '') {
  1422. row.feedgroup = this.table2.temp.fname
  1423. } else {
  1424. if (row.isCreate == true) { // 新增状态下
  1425. for (let i = 1; i < this.table2.list.length; i++) {
  1426. if (this.table2.list[i].sort == row.sort) {
  1427. console.log(this.table2.list[i])
  1428. row.feedgroup = this.table2.list[i].feedgroup
  1429. break
  1430. } else {
  1431. row.feedgroup = this.table2.temp.fname
  1432. }
  1433. }
  1434. } else if (row.isUpdateSave == true) { // 编辑状态下
  1435. for (let i = 0; i < this.table2.list.length; i++) {
  1436. console.log(this.table2.list[i].sort, row.sort)
  1437. if (this.table2.list[i].sort == row.sort) {
  1438. row.feedgroup = this.table2.list[i].feedgroup
  1439. console.log(111, this.table2.list[i].feedgroup)
  1440. break
  1441. } else {
  1442. row.feedgroup = this.table2.temp.fname
  1443. console.log(222, this.table2.temp.fname)
  1444. }
  1445. }
  1446. }
  1447. }
  1448. },
  1449. blurSort(row) {
  1450. if (row.isCreate == true) {
  1451. if (row.sort !== '') {
  1452. for (let i = 1; i < this.table2.list.length; i++) {
  1453. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1454. row.feedgroup = this.table2.list[i].feedgroup
  1455. return false
  1456. } else {
  1457. row.feedgroup = row.fname
  1458. }
  1459. }
  1460. } else {
  1461. row.feedgroup = row.fname
  1462. }
  1463. } else if (row.isUpdateSave == true) {
  1464. console.log(1111)
  1465. if (row.sort !== '') {
  1466. for (let i = 0; i < this.table2.list.length; i++) {
  1467. if (this.table2.list[i].sort == row.sort) {
  1468. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1469. if (this.table2.list[i].id !== row.id) {
  1470. row.isGroupDisabled = true
  1471. row.feedgroup = this.table2.list[i].feedgroup
  1472. break
  1473. }
  1474. } else {
  1475. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1476. row.isGroupDisabled = true
  1477. row.feedgroup = row.fname
  1478. }
  1479. }
  1480. } else {
  1481. row.feedgroup = row.fname
  1482. }
  1483. }
  1484. },
  1485. createData2(row) {
  1486. console.log('点击了详情新增保存', row)
  1487. this.table2.temp.pastureid = Cookies.get('pastureid')
  1488. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1489. this.table2.temp.fid = row.fid
  1490. this.table2.temp.fname = this.table2.temp.fname
  1491. this.table2.temp.fweight = row.fweight
  1492. this.table2.temp.islockcount = row.islockcount
  1493. this.table2.temp.sort = row.sort
  1494. this.table2.temp.feedgroup = row.feedgroup
  1495. this.table2.temp.preftid = this.table2.temp.preftid
  1496. this.table2.temp.autosecond = row.autosecond
  1497. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1498. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1499. return false
  1500. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1501. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1502. return false
  1503. } else if (this.table2.temp.fid == '') {
  1504. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1505. return false
  1506. } else if (this.table2.temp.fweight == '') {
  1507. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1508. return false
  1509. } else if (this.table2.temp.autosecond == '') {
  1510. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1511. return false
  1512. }
  1513. if (this.table2.temp.sort !== '') {
  1514. this.table2.temp.sort = this.table2.temp.sort
  1515. } else {
  1516. console.log(this.table2.list.length)
  1517. if (this.table2.list.length == 1) {
  1518. this.table2.temp.sort = 0
  1519. } else {
  1520. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1521. }
  1522. }
  1523. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1524. if (parseInt(this.table2.temp.preftid) > 0) {
  1525. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1526. return false
  1527. }
  1528. }
  1529. this.isokDisable = true
  1530. setTimeout(() => {
  1531. this.isokDisable = false
  1532. }, 1000)
  1533. this.requestParam.common = { 'returnmap': '0' }
  1534. this.requestParam.data = []
  1535. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1536. pastureid: this.table2.temp.pastureid,
  1537. ftid: this.table2.getdataListParm.parammaps.ftid,
  1538. fid: row.fid,
  1539. fname: this.table2.temp.fname,
  1540. fweight: row.fweight,
  1541. islockcount: row.islockcount,
  1542. sort: row.sort,
  1543. feedgroup: row.feedgroup,
  1544. preftid: this.table2.temp.preftid,
  1545. autosecond: row.autosecond
  1546. }}
  1547. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1548. pastureid: this.table2.temp.pastureid,
  1549. ftid: this.table2.getdataListParm.parammaps.ftid,
  1550. type: this.table2.getdataListParm.parammaps.fttypeid
  1551. }}
  1552. ExecDataByConfig(this.requestParam).then(response => {
  1553. console.log('新增保存发送参数', this.requestParam)
  1554. if (response.msg !== 'fail') {
  1555. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1556. this.getList2()
  1557. } else {
  1558. failproccess(response, this.$notify)
  1559. }
  1560. })
  1561. },
  1562. createCancel2(row) {
  1563. console.log('点击了详情新增取消')
  1564. for (let i = 0; i < this.table2.list.length; i++) {
  1565. if (row.myId === this.table2.list[i].myId) {
  1566. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1567. }
  1568. if (listIndex > -1) {
  1569. this.table2.list.splice(listIndex, 1)
  1570. return
  1571. }
  1572. }
  1573. },
  1574. // 详情编辑
  1575. handleUpdate2(row) {
  1576. console.log(row)
  1577. row.isGroupDisabled = false
  1578. row.islockcount = String(row.islockcount)
  1579. row.fid = String(row.fid)
  1580. row.autosecond = String(row.autosecond)
  1581. this.table2.temp.fname = row.fname
  1582. this.table2.temp.preftid = row.preftid
  1583. const rowArr = []
  1584. for (let i = 0; i < this.table2.list.length; i++) {
  1585. if (this.table2.list[i].Edit == true) {
  1586. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1587. return false
  1588. }
  1589. rowArr.push(this.table2.list[i].sort)
  1590. }
  1591. console.log(rowArr)
  1592. // for (let i = 0; i < rowArr.length; i++) {
  1593. // if (rowArr[i] == row.sort) {
  1594. // rowArr.splice(i, 1)
  1595. // }
  1596. // }
  1597. // console.log(rowArr)
  1598. for (let i = 0; i < rowArr.length; i++) {
  1599. console.log(rowArr[i], row.sort)
  1600. if (rowArr[i] !== row.sort) {
  1601. // 饲料组编辑false,不可编辑true
  1602. row.groupEdit = false
  1603. row.groupNoEdit = true
  1604. // 编辑true,不可编辑false
  1605. row.Edit = true
  1606. row.NoEdit = false
  1607. // 新增false,编辑false,编辑保存true
  1608. row.isCreate = false
  1609. row.isUpdate = false
  1610. row.isUpdateSave = true
  1611. } else {
  1612. // 饲料组编辑true,不可编辑false
  1613. row.groupEdit = true
  1614. row.groupNoEdit = false
  1615. console.log(222)
  1616. // 编辑true,不可编辑false
  1617. row.Edit = true
  1618. row.NoEdit = false
  1619. // 新增false,编辑false,编辑保存true
  1620. row.isCreate = false
  1621. row.isUpdate = false
  1622. row.isUpdateSave = true
  1623. return false
  1624. }
  1625. }
  1626. },
  1627. updateData2(row) {
  1628. console.log('点击了详情编辑保存', row)
  1629. this.isokDisable = true
  1630. setTimeout(() => {
  1631. this.isokDisable = false
  1632. }, 1000)
  1633. this.table2.temp.pastureid = row.pastureid
  1634. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1635. this.table2.temp.fid = row.fid
  1636. this.table2.temp.fname = this.table2.temp.fname
  1637. this.table2.temp.fweight = row.fweight
  1638. this.table2.temp.islockcount = row.islockcount
  1639. this.table2.temp.sort = row.sort
  1640. this.table2.temp.feedgroup = row.feedgroup
  1641. this.table2.temp.preftid = this.table2.temp.preftid
  1642. this.table2.temp.autosecond = row.autosecond
  1643. this.table2.temp.id = row.id
  1644. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1645. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1646. return false
  1647. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1648. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1649. return false
  1650. } else if (this.table2.temp.fid == '') {
  1651. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1652. return false
  1653. } else if (this.table2.temp.fweight == '') {
  1654. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1655. return false
  1656. } else if (this.table2.temp.autosecond == '') {
  1657. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1658. return false
  1659. }
  1660. if (this.table2.temp.sort !== '') {
  1661. this.table2.temp.sort = this.table2.temp.sort
  1662. } else {
  1663. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1664. }
  1665. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1666. if (parseInt(this.table2.temp.preftid) > 0) {
  1667. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1668. return false
  1669. }
  1670. }
  1671. this.requestParam.common = { 'returnmap': '0' }
  1672. this.requestParam.data = []
  1673. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1674. pastureid: row.pastureid,
  1675. ftid: this.table2.getdataListParm.parammaps.ftid,
  1676. fid: row.fid,
  1677. fname: this.table2.temp.fname,
  1678. fweight: row.fweight,
  1679. islockcount: row.islockcount,
  1680. sort: row.sort,
  1681. feedgroup: row.feedgroup,
  1682. preftid: this.table2.temp.preftid,
  1683. autosecond: row.autosecond,
  1684. id: row.id
  1685. }}
  1686. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1687. pastureid: row.pastureid,
  1688. ftid: this.table2.getdataListParm.parammaps.ftid,
  1689. type: this.table2.getdataListParm.parammaps.fttypeid
  1690. }}
  1691. ExecDataByConfig(this.requestParam).then(response => {
  1692. console.log('新增保存发送参数', this.requestParam)
  1693. if (response.msg !== 'fail') {
  1694. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1695. this.getList2()
  1696. } else {
  1697. failproccess(response, this.$notify)
  1698. }
  1699. })
  1700. },
  1701. updateCancel2(row) {
  1702. console.log('点击了详情编辑取消')
  1703. // 饲料组编辑false,不可编辑true
  1704. row.groupEdit = false
  1705. row.groupNoEdit = true
  1706. // 编辑false,不可编辑true
  1707. row.Edit = false
  1708. row.NoEdit = true
  1709. // 新增false,编辑true,编辑保存false
  1710. row.isCreate = false
  1711. row.isUpdate = true
  1712. row.isUpdateSave = false
  1713. this.getList2()
  1714. },
  1715. // 详情删除
  1716. handleRowDelete2(row) {
  1717. console.log('点击了行内删除')
  1718. MessageBox.confirm('是否确认删除此信息?', {
  1719. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1720. }).then(() => {
  1721. this.requestParam.common = { 'returnmap': '0' }
  1722. this.requestParam.data = []
  1723. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1724. pastureid: row.pastureid,
  1725. id: row.id
  1726. }}
  1727. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1728. pastureid: row.pastureid,
  1729. ftid: this.table2.getdataListParm.parammaps.ftid,
  1730. type: this.table2.getdataListParm.parammaps.fttypeid
  1731. }}
  1732. ExecDataByConfig(this.requestParam).then(response => {
  1733. console.log('新增保存发送参数', this.requestParam)
  1734. if (response.msg === 'fail') {
  1735. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1736. } else {
  1737. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1738. this.getList2()
  1739. }
  1740. })
  1741. }).catch(() => {
  1742. this.$message({ type: 'info', message: '已取消删除' })
  1743. })
  1744. },
  1745. handleSelectionChange2(val) {
  1746. console.log('勾选数据', val)
  1747. this.selectList2 = val
  1748. },
  1749. handleDelete2() {
  1750. console.log('点击了删除')
  1751. if (this.selectList2.length == 0) {
  1752. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1753. } else {
  1754. MessageBox.confirm('是否确认删除此信息?', {
  1755. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1756. }).then(() => {
  1757. console.log(this.selectList)
  1758. this.requestParam.common = { 'returnmap': '0' }
  1759. this.requestParam.data = []
  1760. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1761. this.requestParam.data[0].children = []
  1762. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1763. id: '@insertSpotList.id',
  1764. pastureid: '@insertSpotList.pastureid'
  1765. }}
  1766. ExecDataByConfig(this.requestParam).then(response => {
  1767. console.log('删除保存发送参数', this.requestParam)
  1768. if (response.msg === 'fail') {
  1769. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1770. } else {
  1771. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1772. this.getList2()
  1773. }
  1774. })
  1775. })
  1776. }
  1777. },
  1778. // 拆分预混料
  1779. handleSplitPremix(row) {
  1780. console.log('点击了拆分预混料')
  1781. MessageBox.confirm('是否确认拆分当前预混料?', {
  1782. confirmButtonText: '确认',
  1783. cancelButtonText: '取消',
  1784. type: 'warning'
  1785. }).then(() => {
  1786. this.requestParam.name = 'splitFTpre'
  1787. this.requestParam.parammaps = {}
  1788. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1789. this.requestParam.parammaps.preftid = row.preftid
  1790. this.requestParam.parammaps.ftdid = row.id
  1791. this.requestParam.parammaps.pastureid = row.pastureid
  1792. this.requestParam.parammaps.feedgroup = row.feedgroup
  1793. this.requestParam.parammaps.sort = row.sort
  1794. this.requestParam.parammaps.fweight = row.fweight
  1795. PostDataByName(this.requestParam).then(response => {
  1796. if (response.msg === 'fail') {
  1797. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1798. } else {
  1799. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1800. this.getList2()
  1801. }
  1802. })
  1803. }).catch(() => {
  1804. this.$message({
  1805. type: 'info',
  1806. message: '已取消删除'
  1807. })
  1808. })
  1809. },
  1810. // 合成预混料
  1811. handleSyntheticPremix() {
  1812. console.log('点击了合成预混料', this.selectList2)
  1813. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1814. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1815. return false
  1816. } else {
  1817. if (this.selectList2.length > 1) {
  1818. for (let i = 0; i < this.selectList2.length; i++) {
  1819. if (parseInt(this.selectList2[i].preftid) > 0) {
  1820. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1821. return false
  1822. }
  1823. }
  1824. if (this.selectList2[0].splitftpreid !== undefined) {
  1825. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1826. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1827. GetDataByName(this.detail.getdataListParm).then(response => {
  1828. if (response.data.list !== null) { // 不为空时得到比对数据
  1829. this.detail.list3 = response.data.list
  1830. const sortList = [] // 声明排序数组
  1831. var fweightSum = 0 // 总重量
  1832. for (let i = 0; i < this.selectList2.length; i++) {
  1833. const obj = {}
  1834. obj.fid = this.selectList2[i].fid
  1835. obj.fweight = this.selectList2[i].fweight
  1836. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1837. sortList.push(obj)
  1838. }
  1839. // 排序
  1840. sortList.sort(function(a, b) {
  1841. return a.fid.localeCompare(b.fid)
  1842. })
  1843. var a = 0
  1844. if (this.detail.list3.length == sortList.length) {
  1845. for (let i = 0; i < this.detail.list3.length; i++) {
  1846. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  1847. a++
  1848. }
  1849. }
  1850. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1851. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1852. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1853. GetDataByName(this.detail.getdataListParm2).then(response => {
  1854. if (response.data.list !== null) {
  1855. this.detail.dialogStatus = 'SyntheticPremix'
  1856. this.detail.dialogFormVisible = true
  1857. this.detail.list = this.selectList2
  1858. this.detail.list2 = response.data.list
  1859. this.detail.disabled = true
  1860. setTimeout(() => {
  1861. this.detail.listLoading = false
  1862. }, 100)
  1863. } else {
  1864. this.detail.list2 = []
  1865. }
  1866. })
  1867. } else {
  1868. this.detail.dialogStatus = 'SyntheticPremix'
  1869. this.detail.dialogFormVisible = true
  1870. this.detail.list = this.selectList2
  1871. this.detail.disabled = false
  1872. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1873. setTimeout(() => {
  1874. this.detail.listLoading = false
  1875. }, 100)
  1876. }
  1877. } else {
  1878. this.detail.dialogStatus = 'SyntheticPremix'
  1879. this.detail.dialogFormVisible = true
  1880. this.detail.list = this.selectList2
  1881. this.detail.disabled = false
  1882. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1883. setTimeout(() => {
  1884. this.detail.listLoading = false
  1885. }, 100)
  1886. }
  1887. } else {
  1888. this.detail.list3 = []
  1889. this.detail.dialogStatus = 'SyntheticPremix'
  1890. this.detail.dialogFormVisible = true
  1891. this.detail.list = this.selectList2
  1892. this.detail.disabled = false
  1893. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1894. setTimeout(() => {
  1895. this.detail.listLoading = false
  1896. }, 100)
  1897. }
  1898. })
  1899. } else {
  1900. this.detail.dialogStatus = 'SyntheticPremix'
  1901. this.detail.dialogFormVisible = true
  1902. this.detail.list = this.selectList2
  1903. this.detail.disabled = false
  1904. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1905. setTimeout(() => {
  1906. this.detail.listLoading = false
  1907. }, 100)
  1908. }
  1909. } else {
  1910. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1911. return false
  1912. }
  1913. }
  1914. },
  1915. // 畜生类别
  1916. changeLivestockType2(item) {
  1917. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1918. },
  1919. syntheticPremixData() {
  1920. console.log('点击了合成预混料确认')
  1921. if (this.detail.disabled == true) { // 原预混料
  1922. let sumFweight = 0
  1923. for (let i = 0; i < this.detail.list.length; i++) {
  1924. sumFweight += parseFloat(this.detail.list[i].fweight)
  1925. }
  1926. sumFweight = sumFweight.toFixed(2)
  1927. this.isokDisable = true
  1928. setTimeout(() => {
  1929. this.isokDisable = false
  1930. }, 1000)
  1931. this.requestParam.common = { 'returnmap': '0' }
  1932. this.requestParam.data = []
  1933. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  1934. this.requestParam.data[0].children = []
  1935. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1936. pastureid: '@insertSpotList.pastureid',
  1937. id: '@insertSpotList.id'
  1938. }}
  1939. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  1940. this.requestParam.data[1].children = []
  1941. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1942. pastureid: Cookies.get('pastureid'),
  1943. ftid: this.table2.getdataListParm.parammaps.ftid,
  1944. fid: this.detail.list2[0].id,
  1945. fname: '@insertSpotList2.tname',
  1946. fweight: sumFweight,
  1947. islockcount: '0',
  1948. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  1949. feedgroup: this.detail.list[0].feedgroup,
  1950. preftid: this.detail.list2[0].id,
  1951. autosecond: this.detail.list[0].autosecond
  1952. }}
  1953. ExecDataByConfig(this.requestParam).then(response => {
  1954. console.log('合成预混料保存发送参数', this.requestParam)
  1955. if (response.msg === 'fail') {
  1956. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1957. } else {
  1958. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  1959. this.detail.dialogFormVisible = false
  1960. this.getList()
  1961. this.getList2()
  1962. }
  1963. })
  1964. } else { // 现生成预混料
  1965. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  1966. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  1967. return false
  1968. } else if (this.detail.list2[0].tname == '') {
  1969. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1970. return false
  1971. } else if (this.detail.list2[0].ccid == '') {
  1972. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1973. return false
  1974. }
  1975. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1976. if (pattern.test(this.detail.list2[0].tname)) {
  1977. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1978. return false
  1979. }
  1980. let sumFweight = 0
  1981. for (let i = 0; i < this.detail.list.length; i++) {
  1982. sumFweight += parseFloat(this.detail.list[i].fweight)
  1983. }
  1984. sumFweight = sumFweight.toFixed(2)
  1985. console.log(sumFweight)
  1986. this.isokDisable = true
  1987. setTimeout(() => {
  1988. this.isokDisable = false
  1989. }, 1000)
  1990. this.requestParam.common = { 'returnmap': '0' }
  1991. this.requestParam.data = []
  1992. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  1993. pastureid: Cookies.get('pastureid'),
  1994. tcode: this.detail.list2[0].tcode,
  1995. tname: this.detail.list2[0].tname,
  1996. tcolor: this.detail.list2[0].tcolor,
  1997. ccid: this.detail.list2[0].ccid,
  1998. ccname: this.detail.list2[0].ccname,
  1999. fttype: this.detail.list2[0].fttype,
  2000. fttypeid: this.detail.list2[0].fttypeid,
  2001. source: this.detail.list2[0].source,
  2002. remark: this.detail.list2[0].remark,
  2003. enable: this.detail.list2[0].enable
  2004. }}
  2005. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2006. this.requestParam.data[1].children = []
  2007. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2008. pastureid: '@insertSpotList.pastureid',
  2009. ftid: '@insertFT.LastInsertId',
  2010. fid: '@insertSpotList.fid',
  2011. fname: '@insertSpotList.fname',
  2012. fweight: '@insertSpotList.fweight',
  2013. islockcount: '@insertSpotList.islockcount',
  2014. sort: '@insertSpotList.sort',
  2015. feedgroup: '@insertSpotList.feedgroup',
  2016. preftid: '@insertSpotList.preftid',
  2017. autosecond: '@insertSpotList.autosecond'
  2018. }}
  2019. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2020. pastureid: '@insertSpotList.pastureid',
  2021. id: '@insertSpotList.id'
  2022. }}
  2023. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2024. this.requestParam.data[2].children = []
  2025. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2026. pastureid: Cookies.get('pastureid'),
  2027. ftid: this.table2.getdataListParm.parammaps.ftid,
  2028. fid: '@insertFT.LastInsertId',
  2029. fname: '@insertSpotList2.tname',
  2030. fweight: sumFweight,
  2031. islockcount: '0',
  2032. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2033. feedgroup: this.detail.list[0].feedgroup,
  2034. preftid: '@insertFT.LastInsertId',
  2035. autosecond: this.detail.list[0].autosecond
  2036. }}
  2037. ExecDataByConfig(this.requestParam).then(response => {
  2038. console.log('合成预混料保存发送参数', this.requestParam)
  2039. if (response.msg === 'fail') {
  2040. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2041. } else {
  2042. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2043. this.detail.dialogFormVisible = false
  2044. this.getList()
  2045. this.getList2()
  2046. }
  2047. })
  2048. }
  2049. }
  2050. }
  2051. }
  2052. </script>
  2053. <style lang="scss" scoped>
  2054. .search{margin-top:10px;}
  2055. .table{margin-top:10px;}
  2056. .table2{margin-top:10px;}
  2057. $width:350px;
  2058. $left:325px;
  2059. .selectInput{
  2060. position: relative;
  2061. display: inline-block;
  2062. .Input{width: $width;position: relative;}
  2063. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2064. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2065. .selectUl{
  2066. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2067. li{
  2068. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2069. a{float:left;width: 80px;}
  2070. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2071. }
  2072. }
  2073. }
  2074. .template{
  2075. background: #fff;
  2076. position: relative;
  2077. .recipeTemplate{
  2078. width: 72px;
  2079. height: 70px;
  2080. position: absolute;
  2081. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2082. right: 0;
  2083. top: 0;
  2084. margin: 0;
  2085. }
  2086. }
  2087. .detail{
  2088. background: #fff;
  2089. position: relative;
  2090. .recipeDetail{
  2091. width: 72px;
  2092. height: 70px;
  2093. position: absolute;
  2094. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2095. right: 0;
  2096. top: 0;
  2097. margin: 0;
  2098. }
  2099. }
  2100. .templateDialog{
  2101. background: #fff;
  2102. position: relative;
  2103. .recipeTemplate{
  2104. width: 72px;
  2105. height: 70px;
  2106. position: absolute;
  2107. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2108. right: 0;
  2109. top: 0;
  2110. margin: 0;
  2111. }
  2112. }
  2113. .detailDialog{
  2114. background: #fff;
  2115. position: relative;
  2116. .recipeDetail{
  2117. width: 72px;
  2118. height: 70px;
  2119. position: absolute;
  2120. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2121. right: 0;
  2122. top: 0;
  2123. margin: 0;
  2124. }
  2125. }
  2126. </style>