c5284d252a8aaf1dc1a889a913300f5b3ac8a68c.svn-base 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233
  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" width="60" />
  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" filterable 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 && row.isUpdateSave==false" 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. this.getList()
  1003. },
  1004. // 删除
  1005. handleRowDelete(row) {
  1006. console.log('点击了行内删除')
  1007. MessageBox.confirm('是否确认删除此信息?', {
  1008. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1009. }).then(() => {
  1010. this.requestParam.common = { 'returnmap': '0' }
  1011. this.requestParam.data = []
  1012. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1013. pastureid: row.pastureid,
  1014. id: row.id
  1015. }}
  1016. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1017. pastureid: row.pastureid,
  1018. id: row.id
  1019. }}
  1020. ExecDataByConfig(this.requestParam).then(response => {
  1021. console.log('新增保存发送参数', this.requestParam)
  1022. if (response.msg === 'fail') {
  1023. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1024. } else {
  1025. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1026. this.getList()
  1027. }
  1028. })
  1029. }).catch(() => {
  1030. this.$message({ type: 'info', message: '已取消删除' })
  1031. })
  1032. },
  1033. handleSelectionChange(val) {
  1034. console.log('勾选数据', val)
  1035. this.selectList = val
  1036. },
  1037. handleDelete() {
  1038. console.log('点击了删除')
  1039. if (this.selectList.length == 0) {
  1040. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1041. } else {
  1042. MessageBox.confirm('是否确认删除此信息?', {
  1043. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1044. }).then(() => {
  1045. console.log(this.selectList)
  1046. this.requestParam.common = { 'returnmap': '0' }
  1047. this.requestParam.data = []
  1048. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1049. this.requestParam.data[0].children = []
  1050. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1051. id: '@insertSpotList.id',
  1052. pastureid: '@insertSpotList.pastureid'
  1053. }}
  1054. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1055. id: '@insertSpotList.id',
  1056. pastureid: '@insertSpotList.pastureid'
  1057. }}
  1058. ExecDataByConfig(this.requestParam).then(response => {
  1059. console.log('删除保存发送参数', this.requestParam)
  1060. if (response.msg === 'fail') {
  1061. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1062. } else {
  1063. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1064. this.getList()
  1065. }
  1066. })
  1067. })
  1068. }
  1069. },
  1070. // 复制
  1071. handleCopy() {
  1072. if (this.selectList.length == 0) {
  1073. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1074. } else {
  1075. MessageBox.confirm('是否确认复制此信息?', {
  1076. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1077. }).then(() => {
  1078. console.log(this.selectList)
  1079. this.requestParam.common = { 'returnmap': '0' }
  1080. this.requestParam.data = []
  1081. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1082. this.requestParam.data[0].children = []
  1083. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1084. ftid: '@insertSpotList.id',
  1085. pastureid: '@insertSpotList.pastureid'
  1086. }}
  1087. ExecDataByConfig(this.requestParam).then(response => {
  1088. console.log('复制保存发送参数', this.requestParam)
  1089. if (response.msg === 'fail') {
  1090. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1091. } else {
  1092. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1093. this.getList()
  1094. }
  1095. })
  1096. })
  1097. }
  1098. },
  1099. // 配方记录
  1100. handleRecipeRecord() {
  1101. console.log('点击了配方记录')
  1102. this.template.dialogStatus = 'RecipeRecord'
  1103. this.template.dialogFormVisible = true
  1104. this.template.table.getdataListParm.parammaps.ccname = ''
  1105. this.template.table.getdataListParm.parammaps.fttype = ''
  1106. this.template.table.getdataListParm.parammaps.enable = ''
  1107. this.template.table.getdataListParm.parammaps.tname = ''
  1108. this.template.table.getdataListParm.parammaps.remark = ''
  1109. this.template.table.getdataListParm.parammaps.source = ''
  1110. this.template.table.getdataListParm.offset = 1
  1111. this.getDateList()
  1112. this.isDetailDialog = false
  1113. },
  1114. // 历史时间
  1115. getDateList() {
  1116. GetDataByName(this.template.getdataDateParm).then(response => {
  1117. console.log('table数据', response.data.list)
  1118. if (response.data.list !== null) {
  1119. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1120. this.getTemplateDialogList()
  1121. } else {
  1122. this.template.table.getdataListParm.parammaps.date = ''
  1123. }
  1124. })
  1125. },
  1126. // 配方记录-模板
  1127. getTemplateDialogList() {
  1128. this.template.table.listLoading = true
  1129. GetDataByName(this.template.table.getdataListParm).then(response => {
  1130. console.log('table数据', response.data.list)
  1131. if (response.data.list !== null) {
  1132. this.template.table.list = response.data.list
  1133. this.template.table.pageNum = response.data.pageNum
  1134. this.template.table.pageSize = response.data.pageSize
  1135. this.template.table.total = response.data.total
  1136. } else {
  1137. this.template.table.list = []
  1138. }
  1139. setTimeout(() => {
  1140. this.template.table.listLoading = false
  1141. }, 100)
  1142. })
  1143. },
  1144. handleDialogSearch() {
  1145. this.template.table.getdataListParm.offset = 1
  1146. this.getTemplateDialogList()
  1147. this.arrowDown = true
  1148. this.arrowUp = false
  1149. },
  1150. handleDialogRefresh() {
  1151. this.template.table.getdataListParm.parammaps.ccname = ''
  1152. this.template.table.getdataListParm.parammaps.fttype = ''
  1153. this.template.table.getdataListParm.parammaps.enable = ''
  1154. this.template.table.getdataListParm.parammaps.tname = ''
  1155. this.template.table.getdataListParm.parammaps.remark = ''
  1156. this.template.table.getdataListParm.parammaps.source = ''
  1157. this.template.table.getdataListParm.offset = 1
  1158. this.getTemplateDialogList()
  1159. },
  1160. // 配方记录-模板行点击
  1161. tableRowClickDialog(row, column, event) {
  1162. console.log('配方记录-模板行点击')
  1163. this.isDetailDialog = true
  1164. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1165. this.getDialogList()
  1166. this.getDownList()
  1167. },
  1168. getDialogList() {
  1169. this.template.table2.listLoading = true
  1170. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1171. console.log('table数据', response.data.list)
  1172. if (response.data.list !== null) {
  1173. this.template.table2.list = response.data.list
  1174. this.template.table2.pageNum = response.data.pageNum
  1175. this.template.table2.pageSize = response.data.pageSize
  1176. this.template.table2.total = response.data.total
  1177. } else {
  1178. this.template.table2.list = []
  1179. }
  1180. setTimeout(() => {
  1181. this.template.table2.listLoading = false
  1182. }, 100)
  1183. })
  1184. },
  1185. handleDialogSearch2() {
  1186. console.log('点击了查询')
  1187. this.arrowDown2 = true
  1188. this.arrowUp2 = false
  1189. this.template.table2.getdataListParm.offset = 1
  1190. this.getDialogList2()
  1191. },
  1192. handleDialogRefresh2() {
  1193. console.log('点击了重置')
  1194. this.template.table2.getdataListParm.parammaps.fname = ''
  1195. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1196. this.template.table2.getdataListParm.parammaps.fweight = ''
  1197. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1198. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1199. this.template.table2.getdataListParm.parammaps.sort = ''
  1200. this.template.table2.getdataListParm.offset = 1
  1201. this.getDialogList2()
  1202. },
  1203. getDialogList2() {
  1204. this.template.table2.listLoading = true
  1205. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1206. console.log('table数据', response.data.list)
  1207. if (response.data.list !== null) {
  1208. this.template.table2.list = response.data.list
  1209. this.template.table2.pageNum = response.data.pageNum
  1210. this.template.table2.pageSize = response.data.pageSize
  1211. this.template.table2.total = response.data.total
  1212. } else {
  1213. this.template.table2.list = []
  1214. }
  1215. this.$nextTick(function() {
  1216. window.scrollTo({
  1217. 'top': this.$refs.templateDialog.clientHeight
  1218. })
  1219. })
  1220. setTimeout(() => {
  1221. this.template.table2.listLoading = false
  1222. }, 100)
  1223. })
  1224. },
  1225. handleImport() {
  1226. console.log('点击了导入')
  1227. },
  1228. handleExport() {
  1229. console.log('点击了导出')
  1230. },
  1231. changeDate() {
  1232. this.getTemplateDialogList()
  1233. },
  1234. // 应用
  1235. handleApplication() {
  1236. console.log('点击了应用')
  1237. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1238. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1239. }).then(() => {
  1240. this.requestParam.name = 'applyFTdate'
  1241. this.requestParam.parammaps = {}
  1242. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1243. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1244. PostDataByName(this.requestParam).then(response => {
  1245. if (response.msg === 'fail') {
  1246. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1247. } else {
  1248. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1249. this.getTemplateDialogList()
  1250. this.getList()
  1251. }
  1252. })
  1253. }).catch(() => {
  1254. this.$message({ type: 'info', message: '已取消应用' })
  1255. })
  1256. },
  1257. // 模板行点击
  1258. tableRowClick(row, column, event) {
  1259. console.log(row, column, event)
  1260. for (let i = 0; i < this.table.list.length; i++) {
  1261. if (this.table.list[i].Edit == true) {
  1262. return false
  1263. }
  1264. }
  1265. if (column.label !== '操作') {
  1266. this.isDetail = true // 点击行显示详情
  1267. this.table2.getdataListParm.parammaps.ftid = row.id
  1268. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1269. this.getList2()
  1270. this.getDownList()
  1271. }
  1272. },
  1273. // -------------------详情-----------------------------
  1274. // 获取是否显示是否锁定牛头数
  1275. getIsLockCount() {
  1276. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1277. console.log(response.data.list)
  1278. if (response.data.list[0].inforvalue == 0) {
  1279. this.lockCount.isLockCount = false
  1280. } else {
  1281. this.lockCount.isLockCount = true
  1282. }
  1283. })
  1284. },
  1285. // 详情
  1286. getList2() {
  1287. this.table2.listLoading = true
  1288. GetDataByName(this.table2.getdataListParm).then(response => {
  1289. console.log('table数据', response.data.list)
  1290. if (response.data.list !== null) {
  1291. for (let i = 0; i < response.data.list.length; i++) {
  1292. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1293. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1294. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1295. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1296. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1297. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1298. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1299. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1300. }
  1301. this.rowDrop()
  1302. this.table2.list = response.data.list
  1303. this.table2.pageNum = response.data.pageNum
  1304. this.table2.pageSize = response.data.pageSize
  1305. this.table2.total = response.data.total
  1306. } else {
  1307. this.table2.list = []
  1308. }
  1309. this.$nextTick(function() {
  1310. console.log(this.$refs)
  1311. console.log(this.$refs.template.clientHeight)
  1312. window.scrollTo({
  1313. 'top': this.$refs.template.clientHeight
  1314. })
  1315. })
  1316. setTimeout(() => {
  1317. this.table2.listLoading = false
  1318. }, 100)
  1319. })
  1320. },
  1321. // 行拖拽
  1322. rowDrop() {
  1323. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1324. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1325. const that = this
  1326. Sortable.create(tbody, {
  1327. onEnd({ newIndex, oldIndex }) {
  1328. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1329. that.table2.list.splice(newIndex, 0, currRow)
  1330. console.log('索引', newIndex)
  1331. console.log('拖动数据', currRow)
  1332. console.log('上', that.table2.list[newIndex - 1])
  1333. console.log('下', that.table2.list[newIndex + 1])
  1334. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1335. for (let i = 0; i < that.table2.list.length; i++) {
  1336. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1337. }
  1338. currRow.sort = 0
  1339. currRow.feedgroup = currRow.fname
  1340. console.log('拖动至最上方无值')
  1341. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1342. currRow.sort = that.table2.list[newIndex - 1].sort
  1343. console.log('拖动值顺序等于上值顺序')
  1344. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1345. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1346. currRow.feedgroup = currRow.fname
  1347. console.log('拖动至最下方无值')
  1348. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1349. currRow.sort == that.table2.list[newIndex + 1].sort
  1350. console.log('拖动值顺序等于下值顺序')
  1351. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1352. currRow.sort = that.table2.list[newIndex - 1].sort
  1353. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1354. console.log('拖动至上下顺序一致')
  1355. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1356. console.log('上下')
  1357. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1358. console.log(newIndex)
  1359. for (let i = newIndex; i < that.table2.list.length; i++) {
  1360. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1361. }
  1362. }
  1363. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1364. currRow.feedgroup = currRow.fname
  1365. console.log(that.table2.list[newIndex + 1].sort)
  1366. }
  1367. that.requestParam = {}
  1368. that.requestParam.common = { 'returnmap': '0' }
  1369. that.requestParam.data = []
  1370. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1371. that.requestParam.data[0].children = []
  1372. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1373. id: '@insertSpotList.id',
  1374. pastureid: '@insertSpotList.pastureid',
  1375. sort: '@insertSpotList.sort',
  1376. feedgroup: '@insertSpotList.feedgroup'
  1377. }}
  1378. ExecDataByConfig(that.requestParam).then(response => {
  1379. console.log('顺序切换保存发送参数', that.requestParam)
  1380. if (response.msg === 'fail') {
  1381. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1382. } else {
  1383. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1384. that.getList2()
  1385. }
  1386. })
  1387. }
  1388. })
  1389. },
  1390. handleSearch2() {
  1391. console.log('点击了查询')
  1392. this.arrowDown2 = true
  1393. this.arrowUp2 = false
  1394. this.table2.getdataListParm.offset = 1
  1395. this.getList2()
  1396. },
  1397. handleRefresh2() {
  1398. console.log('点击了重置')
  1399. this.table2.getdataListParm.parammaps.fname = ''
  1400. this.table2.getdataListParm.parammaps.feedgroup = ''
  1401. this.table2.getdataListParm.parammaps.fweight = ''
  1402. this.table2.getdataListParm.parammaps.autosecondname = ''
  1403. this.table2.getdataListParm.parammaps.islockcount = '0'
  1404. this.table2.getdataListParm.parammaps.sort = ''
  1405. this.table2.getdataListParm.offset = 1
  1406. this.getList2()
  1407. },
  1408. // 详情新增
  1409. handleCreate2() {
  1410. console.log('点击了详情新增', this.table2.list)
  1411. // 编辑true/不可编辑false
  1412. // 新增操true,编辑false,编辑保存false
  1413. console.log(11)
  1414. for (let i = 0; i < this.table2.list.length; i++) {
  1415. if (this.table2.list[i].Edit === true) {
  1416. console.log(123)
  1417. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1418. return false
  1419. }
  1420. }
  1421. console.log(this.table2.list)
  1422. if (this.table2.list.length == 0) {
  1423. var mysort = 0
  1424. } else {
  1425. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1426. }
  1427. 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': '0', 'islockcount': '0', 'sort': mysort })
  1428. console.log(this.table2.list)
  1429. },
  1430. changeFname(item, row) {
  1431. console.log(item, row)
  1432. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1433. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1434. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1435. this.table2.temp.preftid = '0'
  1436. } else {
  1437. this.table2.temp.preftid = item
  1438. }
  1439. if (row.sort == '') {
  1440. row.feedgroup = this.table2.temp.fname
  1441. } else {
  1442. if (row.isCreate == true) { // 新增状态下
  1443. for (let i = 1; i < this.table2.list.length; i++) {
  1444. if (this.table2.list[i].sort == row.sort) {
  1445. console.log(this.table2.list[i])
  1446. row.feedgroup = this.table2.list[i].feedgroup
  1447. break
  1448. } else {
  1449. row.feedgroup = this.table2.temp.fname
  1450. }
  1451. }
  1452. } else if (row.isUpdateSave == true) { // 编辑状态下
  1453. var Arr = []
  1454. for (let i = 0; i < this.table2.list.length; i++) {
  1455. Arr.push(this.table2.list[i].sort)
  1456. }
  1457. var Count = 0
  1458. for (let i = 0; i < Arr.length; i++) {
  1459. if (Arr[i] == row.sort) {
  1460. Count++
  1461. }
  1462. }
  1463. for (let i = 0; i < this.table2.list.length; i++) {
  1464. if (Count > 1) {
  1465. row.feedgroup = this.table2.list[i].feedgroup
  1466. console.log(111, this.table2.list[i].feedgroup)
  1467. break
  1468. } else if (Count == 1) {
  1469. row.feedgroup = this.table2.temp.fname
  1470. console.log(222, this.table2.temp.fname)
  1471. }
  1472. }
  1473. }
  1474. }
  1475. },
  1476. blurSort(row) {
  1477. if (row.isCreate == true) {
  1478. if (row.sort !== '') {
  1479. for (let i = 1; i < this.table2.list.length; i++) {
  1480. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1481. row.feedgroup = this.table2.list[i].feedgroup
  1482. return false
  1483. } else {
  1484. row.feedgroup = row.fname
  1485. }
  1486. }
  1487. } else {
  1488. row.feedgroup = row.fname
  1489. }
  1490. } else if (row.isUpdateSave == true) {
  1491. console.log(1111)
  1492. if (row.sort !== '') {
  1493. for (let i = 0; i < this.table2.list.length; i++) {
  1494. if (this.table2.list[i].sort == row.sort) {
  1495. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1496. if (this.table2.list[i].id !== row.id) {
  1497. row.isGroupDisabled = true
  1498. row.feedgroup = this.table2.list[i].feedgroup
  1499. break
  1500. }
  1501. } else {
  1502. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1503. row.isGroupDisabled = true
  1504. row.feedgroup = row.fname
  1505. }
  1506. }
  1507. } else {
  1508. row.feedgroup = row.fname
  1509. }
  1510. }
  1511. },
  1512. createData2(row) {
  1513. console.log('点击了详情新增保存', row)
  1514. this.table2.temp.pastureid = Cookies.get('pastureid')
  1515. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1516. this.table2.temp.fid = row.fid
  1517. this.table2.temp.fname = this.table2.temp.fname
  1518. this.table2.temp.fweight = row.fweight
  1519. this.table2.temp.islockcount = row.islockcount
  1520. this.table2.temp.sort = row.sort
  1521. this.table2.temp.feedgroup = row.feedgroup
  1522. this.table2.temp.preftid = this.table2.temp.preftid
  1523. this.table2.temp.autosecond = row.autosecond
  1524. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1525. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1526. return false
  1527. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1528. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1529. return false
  1530. } else if (this.table2.temp.fid == '') {
  1531. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1532. return false
  1533. } else if (this.table2.temp.fweight == '') {
  1534. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1535. return false
  1536. } else if (this.table2.temp.autosecond == '') {
  1537. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1538. return false
  1539. }
  1540. if (this.table2.temp.sort !== '') {
  1541. this.table2.temp.sort = this.table2.temp.sort
  1542. } else {
  1543. console.log(this.table2.list.length)
  1544. if (this.table2.list.length == 1) {
  1545. this.table2.temp.sort = 0
  1546. } else {
  1547. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1548. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1549. }
  1550. }
  1551. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1552. if (parseInt(this.table2.temp.preftid) > 0) {
  1553. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1554. return false
  1555. }
  1556. }
  1557. // 校验顺序是否>=0
  1558. var ruleSort = /^\d+$/
  1559. if (!ruleSort.test(this.table2.temp.sort)) {
  1560. this.$message({ type: 'error', message: '饲料顺序不可为负数', duration: 2000 })
  1561. return false
  1562. }
  1563. // 检验重量>0
  1564. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1565. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1566. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1567. return false
  1568. }
  1569. this.isokDisable = true
  1570. setTimeout(() => {
  1571. this.isokDisable = false
  1572. }, 1000)
  1573. this.requestParam.common = { 'returnmap': '0' }
  1574. this.requestParam.data = []
  1575. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1576. pastureid: this.table2.temp.pastureid,
  1577. ftid: this.table2.getdataListParm.parammaps.ftid,
  1578. fid: row.fid,
  1579. fname: this.table2.temp.fname,
  1580. fweight: row.fweight,
  1581. islockcount: row.islockcount,
  1582. sort: row.sort,
  1583. feedgroup: row.feedgroup,
  1584. preftid: this.table2.temp.preftid,
  1585. autosecond: row.autosecond
  1586. }}
  1587. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1588. pastureid: this.table2.temp.pastureid,
  1589. ftid: this.table2.getdataListParm.parammaps.ftid,
  1590. type: this.table2.getdataListParm.parammaps.fttypeid
  1591. }}
  1592. ExecDataByConfig(this.requestParam).then(response => {
  1593. console.log('新增保存发送参数', this.requestParam)
  1594. if (response.msg !== 'fail') {
  1595. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1596. this.getList2()
  1597. } else {
  1598. failproccess(response, this.$notify)
  1599. }
  1600. })
  1601. },
  1602. createCancel2(row) {
  1603. console.log('点击了详情新增取消')
  1604. for (let i = 0; i < this.table2.list.length; i++) {
  1605. if (row.myId === this.table2.list[i].myId) {
  1606. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1607. }
  1608. if (listIndex > -1) {
  1609. this.table2.list.splice(listIndex, 1)
  1610. return
  1611. }
  1612. }
  1613. this.getDialogList()
  1614. },
  1615. // 详情编辑
  1616. handleUpdate2(row) {
  1617. console.log('详情编辑', row)
  1618. row.isGroupDisabled = false
  1619. row.islockcount = String(row.islockcount)
  1620. row.fid = String(row.fid)
  1621. row.autosecond = String(row.autosecond)
  1622. this.table2.temp.fname = row.fname
  1623. this.table2.temp.preftid = row.preftid
  1624. const rowArr = []
  1625. for (let i = 0; i < this.table2.list.length; i++) {
  1626. if (this.table2.list[i].Edit == true) {
  1627. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1628. return false
  1629. }
  1630. rowArr.push(this.table2.list[i].sort)
  1631. }
  1632. var count = 0
  1633. for (let i = 0; i < rowArr.length; i++) {
  1634. if (rowArr[i] == row.sort) {
  1635. count++
  1636. }
  1637. }
  1638. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1639. if (count == 1) {
  1640. // 饲料组编辑false,不可编辑true
  1641. row.groupEdit = false
  1642. row.groupNoEdit = true
  1643. // 编辑true,不可编辑false
  1644. row.Edit = true
  1645. row.NoEdit = false
  1646. // 新增false,编辑false,编辑保存true
  1647. row.isCreate = false
  1648. row.isUpdate = false
  1649. row.isUpdateSave = true
  1650. } else if (count > 1) {
  1651. // 饲料组编辑true,不可编辑false
  1652. row.groupEdit = true
  1653. row.groupNoEdit = false
  1654. console.log(222)
  1655. // 编辑true,不可编辑false
  1656. row.Edit = true
  1657. row.NoEdit = false
  1658. // 新增false,编辑false,编辑保存true
  1659. row.isCreate = false
  1660. row.isUpdate = false
  1661. row.isUpdateSave = true
  1662. return false
  1663. }
  1664. },
  1665. updateData2(row) {
  1666. console.log('点击了详情编辑保存111', row)
  1667. this.isokDisable = true
  1668. setTimeout(() => {
  1669. this.isokDisable = false
  1670. }, 1000)
  1671. this.table2.temp.pastureid = row.pastureid
  1672. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1673. this.table2.temp.fid = row.fid
  1674. this.table2.temp.fname = this.table2.temp.fname
  1675. this.table2.temp.fweight = row.fweight
  1676. this.table2.temp.islockcount = row.islockcount
  1677. this.table2.temp.sort = row.sort
  1678. this.table2.temp.feedgroup = row.feedgroup
  1679. this.table2.temp.preftid = this.table2.temp.preftid
  1680. this.table2.temp.autosecond = row.autosecond
  1681. this.table2.temp.id = row.id
  1682. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1683. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1684. return false
  1685. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1686. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1687. return false
  1688. } else if (this.table2.temp.fid == '') {
  1689. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1690. return false
  1691. } else if (this.table2.temp.fweight == '') {
  1692. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1693. return false
  1694. } else if (this.table2.temp.autosecond == '') {
  1695. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1696. return false
  1697. }
  1698. if (this.table2.temp.sort !== '') {
  1699. this.table2.temp.sort = this.table2.temp.sort
  1700. } else {
  1701. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1702. }
  1703. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1704. if (parseInt(this.table2.temp.preftid) > 0) {
  1705. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1706. return false
  1707. }
  1708. }
  1709. // 校验顺序是否>=0
  1710. var ruleSort = /^\d+$/
  1711. if (!ruleSort.test(this.table2.temp.sort)) {
  1712. this.$message({ type: 'error', message: '饲料顺序不可为负数', duration: 2000 })
  1713. return false
  1714. }
  1715. // 检验重量>0
  1716. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1717. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1718. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1719. return false
  1720. }
  1721. this.requestParam.common = { 'returnmap': '0' }
  1722. this.requestParam.data = []
  1723. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1724. pastureid: row.pastureid,
  1725. ftid: this.table2.getdataListParm.parammaps.ftid,
  1726. fid: row.fid,
  1727. fname: this.table2.temp.fname,
  1728. fweight: row.fweight,
  1729. islockcount: row.islockcount,
  1730. sort: row.sort,
  1731. feedgroup: row.feedgroup,
  1732. preftid: this.table2.temp.preftid,
  1733. autosecond: row.autosecond,
  1734. id: row.id
  1735. }}
  1736. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1737. pastureid: row.pastureid,
  1738. ftid: this.table2.getdataListParm.parammaps.ftid,
  1739. type: this.table2.getdataListParm.parammaps.fttypeid
  1740. }}
  1741. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1742. pastureid: row.pastureid,
  1743. ftid: this.table2.getdataListParm.parammaps.ftid,
  1744. sort: row.sort,
  1745. feedgroup: row.feedgroup
  1746. }}
  1747. ExecDataByConfig(this.requestParam).then(response => {
  1748. console.log('新增保存发送参数', this.requestParam)
  1749. if (response.msg !== 'fail') {
  1750. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1751. this.getList2()
  1752. } else {
  1753. failproccess(response, this.$notify)
  1754. }
  1755. })
  1756. },
  1757. updateCancel2(row) {
  1758. console.log('点击了详情编辑取消')
  1759. // 饲料组编辑false,不可编辑true
  1760. row.groupEdit = false
  1761. row.groupNoEdit = true
  1762. // 编辑false,不可编辑true
  1763. row.Edit = false
  1764. row.NoEdit = true
  1765. // 新增false,编辑true,编辑保存false
  1766. row.isCreate = false
  1767. row.isUpdate = true
  1768. row.isUpdateSave = false
  1769. this.getList2()
  1770. },
  1771. // 详情删除
  1772. handleRowDelete2(row) {
  1773. console.log('点击了行内删除')
  1774. MessageBox.confirm('是否确认删除此信息?', {
  1775. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1776. }).then(() => {
  1777. this.requestParam.common = { 'returnmap': '0' }
  1778. this.requestParam.data = []
  1779. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1780. pastureid: row.pastureid,
  1781. id: row.id
  1782. }}
  1783. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1784. pastureid: row.pastureid,
  1785. ftid: this.table2.getdataListParm.parammaps.ftid,
  1786. type: this.table2.getdataListParm.parammaps.fttypeid
  1787. }}
  1788. ExecDataByConfig(this.requestParam).then(response => {
  1789. console.log('新增保存发送参数', this.requestParam)
  1790. if (response.msg === 'fail') {
  1791. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1792. } else {
  1793. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1794. this.getList2()
  1795. }
  1796. })
  1797. }).catch(() => {
  1798. this.$message({ type: 'info', message: '已取消删除' })
  1799. })
  1800. },
  1801. handleSelectionChange2(val) {
  1802. console.log('勾选数据', val)
  1803. this.selectList2 = val
  1804. },
  1805. handleDelete2() {
  1806. console.log('点击了删除')
  1807. if (this.selectList2.length == 0) {
  1808. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1809. } else {
  1810. MessageBox.confirm('是否确认删除此信息?', {
  1811. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1812. }).then(() => {
  1813. console.log(this.selectList)
  1814. this.requestParam.common = { 'returnmap': '0' }
  1815. this.requestParam.data = []
  1816. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1817. this.requestParam.data[0].children = []
  1818. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1819. id: '@insertSpotList.id',
  1820. pastureid: '@insertSpotList.pastureid'
  1821. }}
  1822. ExecDataByConfig(this.requestParam).then(response => {
  1823. console.log('删除保存发送参数', this.requestParam)
  1824. if (response.msg === 'fail') {
  1825. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1826. } else {
  1827. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1828. this.getList2()
  1829. }
  1830. })
  1831. })
  1832. }
  1833. },
  1834. // 拆分预混料
  1835. handleSplitPremix(row) {
  1836. console.log('点击了拆分预混料')
  1837. MessageBox.confirm('是否确认拆分当前预混料?', {
  1838. confirmButtonText: '确认',
  1839. cancelButtonText: '取消',
  1840. type: 'warning'
  1841. }).then(() => {
  1842. this.requestParam.name = 'splitFTpre'
  1843. this.requestParam.parammaps = {}
  1844. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1845. this.requestParam.parammaps.preftid = row.preftid
  1846. this.requestParam.parammaps.ftdid = row.id
  1847. this.requestParam.parammaps.pastureid = row.pastureid
  1848. this.requestParam.parammaps.feedgroup = row.feedgroup
  1849. this.requestParam.parammaps.sort = row.sort
  1850. this.requestParam.parammaps.fweight = row.fweight
  1851. PostDataByName(this.requestParam).then(response => {
  1852. if (response.msg === 'fail') {
  1853. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1854. } else {
  1855. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1856. this.getList2()
  1857. }
  1858. })
  1859. }).catch(() => {
  1860. this.$message({
  1861. type: 'info',
  1862. message: '已取消删除'
  1863. })
  1864. })
  1865. },
  1866. // 合成预混料
  1867. handleSyntheticPremix() {
  1868. console.log('点击了合成预混料', this.selectList2)
  1869. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1870. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1871. return false
  1872. } else {
  1873. if (this.selectList2.length > 1) {
  1874. for (let i = 0; i < this.selectList2.length; i++) {
  1875. if (parseInt(this.selectList2[i].preftid) > 0) {
  1876. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1877. return false
  1878. }
  1879. }
  1880. if (this.selectList2[0].splitftpreid !== undefined) {
  1881. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1882. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1883. GetDataByName(this.detail.getdataListParm).then(response => {
  1884. if (response.data.list !== null) { // 不为空时得到比对数据
  1885. this.detail.list3 = response.data.list
  1886. const sortList = [] // 声明排序数组
  1887. var fweightSum = 0 // 总重量
  1888. for (let i = 0; i < this.selectList2.length; i++) {
  1889. const obj = {}
  1890. obj.fid = this.selectList2[i].fid
  1891. obj.fweight = this.selectList2[i].fweight
  1892. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1893. sortList.push(obj)
  1894. }
  1895. // 排序
  1896. sortList.sort(function(a, b) {
  1897. return a.fid.localeCompare(b.fid)
  1898. })
  1899. var a = 0
  1900. if (this.detail.list3.length == sortList.length) {
  1901. for (let i = 0; i < this.detail.list3.length; i++) {
  1902. 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)) {
  1903. a++
  1904. }
  1905. }
  1906. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1907. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1908. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1909. GetDataByName(this.detail.getdataListParm2).then(response => {
  1910. if (response.data.list !== null) {
  1911. this.detail.dialogStatus = 'SyntheticPremix'
  1912. this.detail.dialogFormVisible = true
  1913. this.detail.list = this.selectList2
  1914. this.detail.list2 = response.data.list
  1915. this.detail.disabled = true
  1916. setTimeout(() => {
  1917. this.detail.listLoading = false
  1918. }, 100)
  1919. } else {
  1920. this.detail.list2 = []
  1921. }
  1922. })
  1923. } else {
  1924. this.detail.dialogStatus = 'SyntheticPremix'
  1925. this.detail.dialogFormVisible = true
  1926. this.detail.list = this.selectList2
  1927. this.detail.disabled = false
  1928. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1929. setTimeout(() => {
  1930. this.detail.listLoading = false
  1931. }, 100)
  1932. }
  1933. } else {
  1934. this.detail.dialogStatus = 'SyntheticPremix'
  1935. this.detail.dialogFormVisible = true
  1936. this.detail.list = this.selectList2
  1937. this.detail.disabled = false
  1938. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1939. setTimeout(() => {
  1940. this.detail.listLoading = false
  1941. }, 100)
  1942. }
  1943. } else {
  1944. this.detail.list3 = []
  1945. this.detail.dialogStatus = 'SyntheticPremix'
  1946. this.detail.dialogFormVisible = true
  1947. this.detail.list = this.selectList2
  1948. this.detail.disabled = false
  1949. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1950. setTimeout(() => {
  1951. this.detail.listLoading = false
  1952. }, 100)
  1953. }
  1954. })
  1955. } else {
  1956. this.detail.dialogStatus = 'SyntheticPremix'
  1957. this.detail.dialogFormVisible = true
  1958. this.detail.list = this.selectList2
  1959. this.detail.disabled = false
  1960. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1961. setTimeout(() => {
  1962. this.detail.listLoading = false
  1963. }, 100)
  1964. }
  1965. } else {
  1966. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1967. return false
  1968. }
  1969. }
  1970. },
  1971. // 畜生类别
  1972. changeLivestockType2(item) {
  1973. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1974. },
  1975. syntheticPremixData() {
  1976. console.log('点击了合成预混料确认')
  1977. if (this.detail.disabled == true) { // 原预混料
  1978. let sumFweight = 0
  1979. for (let i = 0; i < this.detail.list.length; i++) {
  1980. sumFweight += parseFloat(this.detail.list[i].fweight)
  1981. }
  1982. sumFweight = sumFweight.toFixed(2)
  1983. this.isokDisable = true
  1984. setTimeout(() => {
  1985. this.isokDisable = false
  1986. }, 1000)
  1987. this.requestParam.common = { 'returnmap': '0' }
  1988. this.requestParam.data = []
  1989. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  1990. this.requestParam.data[0].children = []
  1991. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1992. pastureid: '@insertSpotList.pastureid',
  1993. id: '@insertSpotList.id'
  1994. }}
  1995. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  1996. this.requestParam.data[1].children = []
  1997. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1998. pastureid: Cookies.get('pastureid'),
  1999. ftid: this.table2.getdataListParm.parammaps.ftid,
  2000. fid: this.detail.list2[0].id,
  2001. fname: '@insertSpotList2.tname',
  2002. fweight: sumFweight,
  2003. islockcount: '0',
  2004. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2005. feedgroup: '@insertSpotList2.tname',
  2006. preftid: this.detail.list2[0].id,
  2007. autosecond: this.detail.list[0].autosecond
  2008. }}
  2009. ExecDataByConfig(this.requestParam).then(response => {
  2010. console.log('合成预混料保存发送参数', this.requestParam)
  2011. if (response.msg === 'fail') {
  2012. const tname = new RegExp("key 'tname'")
  2013. if (tname.test(response.data)) {
  2014. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2015. } else {
  2016. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2017. }
  2018. } else {
  2019. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2020. this.detail.dialogFormVisible = false
  2021. this.getList()
  2022. this.getList2()
  2023. this.getDownList()
  2024. }
  2025. })
  2026. } else { // 现生成预混料
  2027. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2028. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2029. return false
  2030. } else if (this.detail.list2[0].tname == '') {
  2031. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2032. return false
  2033. } else if (this.detail.list2[0].ccid == '') {
  2034. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2035. return false
  2036. }
  2037. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2038. if (pattern.test(this.detail.list2[0].tname)) {
  2039. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2040. return false
  2041. }
  2042. let sumFweight = 0
  2043. for (let i = 0; i < this.detail.list.length; i++) {
  2044. sumFweight += parseFloat(this.detail.list[i].fweight)
  2045. }
  2046. sumFweight = sumFweight.toFixed(2)
  2047. console.log(sumFweight)
  2048. this.isokDisable = true
  2049. setTimeout(() => {
  2050. this.isokDisable = false
  2051. }, 1000)
  2052. this.requestParam.common = { 'returnmap': '0' }
  2053. this.requestParam.data = []
  2054. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2055. pastureid: Cookies.get('pastureid'),
  2056. tcode: this.detail.list2[0].tcode,
  2057. tname: this.detail.list2[0].tname,
  2058. tcolor: this.detail.list2[0].tcolor,
  2059. ccid: this.detail.list2[0].ccid,
  2060. ccname: this.detail.list2[0].ccname,
  2061. fttype: this.detail.list2[0].fttype,
  2062. fttypeid: this.detail.list2[0].fttypeid,
  2063. source: this.detail.list2[0].source,
  2064. remark: this.detail.list2[0].remark,
  2065. enable: this.detail.list2[0].enable
  2066. }}
  2067. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2068. this.requestParam.data[1].children = []
  2069. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2070. pastureid: '@insertSpotList.pastureid',
  2071. ftid: '@insertFT.LastInsertId',
  2072. fid: '@insertSpotList.fid',
  2073. fname: '@insertSpotList.fname',
  2074. fweight: '@insertSpotList.fweight',
  2075. islockcount: '@insertSpotList.islockcount',
  2076. sort: '@insertSpotList.sort',
  2077. feedgroup: '@insertSpotList.feedgroup',
  2078. preftid: '@insertSpotList.preftid',
  2079. autosecond: '@insertSpotList.autosecond'
  2080. }}
  2081. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2082. pastureid: '@insertSpotList.pastureid',
  2083. id: '@insertSpotList.id'
  2084. }}
  2085. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2086. this.requestParam.data[2].children = []
  2087. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2088. pastureid: Cookies.get('pastureid'),
  2089. ftid: this.table2.getdataListParm.parammaps.ftid,
  2090. fid: '@insertFT.LastInsertId',
  2091. fname: '@insertSpotList2.tname',
  2092. fweight: sumFweight,
  2093. islockcount: '0',
  2094. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2095. feedgroup: '@insertSpotList2.tname',
  2096. preftid: '@insertFT.LastInsertId',
  2097. autosecond: this.detail.list[0].autosecond
  2098. }}
  2099. ExecDataByConfig(this.requestParam).then(response => {
  2100. console.log('合成预混料保存发送参数', this.requestParam)
  2101. if (response.msg === 'fail') {
  2102. const tname = new RegExp("key 'tname'")
  2103. if (tname.test(response.data)) {
  2104. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2105. } else {
  2106. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2107. }
  2108. } else {
  2109. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2110. this.detail.dialogFormVisible = false
  2111. this.getList()
  2112. this.getList2()
  2113. this.getDownList()
  2114. }
  2115. })
  2116. }
  2117. }
  2118. }
  2119. }
  2120. </script>
  2121. <style lang="scss" scoped>
  2122. .search{margin-top:10px;}
  2123. .table{margin-top:10px;}
  2124. .table2{margin-top:10px;}
  2125. $width:350px;
  2126. $left:325px;
  2127. .selectInput{
  2128. position: relative;
  2129. display: inline-block;
  2130. .Input{width: $width;position: relative;}
  2131. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2132. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2133. .selectUl{
  2134. 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;
  2135. li{
  2136. 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;
  2137. a{float:left;width: 80px;}
  2138. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2139. }
  2140. }
  2141. }
  2142. .template{
  2143. background: #fff;
  2144. position: relative;
  2145. .recipeTemplate{
  2146. width: 72px;
  2147. height: 70px;
  2148. position: absolute;
  2149. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2150. right: 0;
  2151. top: 0;
  2152. margin: 0;
  2153. }
  2154. }
  2155. .detail{
  2156. background: #fff;
  2157. position: relative;
  2158. .recipeDetail{
  2159. width: 72px;
  2160. height: 70px;
  2161. position: absolute;
  2162. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2163. right: 0;
  2164. top: 0;
  2165. margin: 0;
  2166. }
  2167. }
  2168. .templateDialog{
  2169. background: #fff;
  2170. position: relative;
  2171. .recipeTemplate{
  2172. width: 72px;
  2173. height: 70px;
  2174. position: absolute;
  2175. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2176. right: 0;
  2177. top: 0;
  2178. margin: 0;
  2179. }
  2180. }
  2181. .detailDialog{
  2182. background: #fff;
  2183. position: relative;
  2184. .recipeDetail{
  2185. width: 72px;
  2186. height: 70px;
  2187. position: absolute;
  2188. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2189. right: 0;
  2190. top: 0;
  2191. margin: 0;
  2192. }
  2193. }
  2194. </style>